954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ASP: Deleting a file

Good afternoon all, does anyone know the necessary codings to delete a file from the Web Server? I have tried the "Scripting-File" object, but it's still not working, any suggestions?

Have a pleasant day...

SeekAnswers
Newbie Poster
20 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

The FSO is the object you need to use. There could be an error in your code which is preventing it from working (wouldn't know without seeing your code), or more likely you do not have/have not set the required permissions on the folder/files you are trying to delete.

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

I have already set up the correct permissions for all the related folders, just that they are still not able to work, and I kept getting the "Internal Server Error: 500", do you have any idea where the problem is?

The codes are shown below, it's just a short one:

Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")

ScriptObject.DeleteFile(filename)

SeekAnswers
Newbie Poster
20 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

First step to help you debug is to turn off 'Show Friendly HTTP error messages' in your browser. This can be done by clicking on the Tools tab on teh toolbar, then Internet Options and select the Advanced tab. Scroll down through the Browsing section and uncheck teh box next to 'Show Friendly HTTP error messages'. Your browser will then display a much more meaningfull error message. Post the new error message here and we'll see what we can do to fix up your problem.

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

Thanks for your help, I have managed to find and solve the error, after changing the settings at the Internet Explorer..

I have added in the "Server.MapPath" method, and it works wonderously...thanks again, buddy...

Enjoy your day....

SeekAnswers
Newbie Poster
20 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

<%
dim FileName,FS1
FileName=Server.MapPath("")
Set FS1 = CreateObject("Scripting.FileSystemObject")
FS1.DeleteFile FileName
%>

For deleting the file, give ur foldername/filename like
FileName=Server.MapPath("Images/test.gif")

If u find this useful inform me...my Id is [email]radha_992@yahoo.co.in[/email]

radharadha
Newbie Poster
6 posts since May 2006
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You