Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dim FSO Set FSO = Server.CreateObj

Status
Not open for further replies.

zakd

Programmer
Dec 11, 2001
21
GR
Dim FSO
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
Dim itemName, itemPath
itemName = "photo.gif"
itemPath = Server.MapPath("Photos") & "\" & itemName
Dim itemFile
Set itemFile = FSO.GetFile (itemPath)
itemFile.Delete


Can anyone tells me why this code doesn't works???
Or let me know how can i delete a file....
Thanks.
 
I think you need a complete path not a relative one.

Try something like:

' delete the document
Dim filesys
Dim file_name
Dim folder

file_name = photo.gif
folder = "F:\Inetpub\Intranet\photos\"
Set filesys=CreateObject("Scripting.FileSystemObject")

if filesys.FileExists(folder & file_name) then
filesys.DeleteFile(folder & file_name)
response.write &quot;<p>You have deleted your document.</p>&quot;
else
response.write &quot;<p>Im sorry but no document with that name can be found.</p>&quot;
end if

Hope this helps

Russell
 
I should probably have put

file_name = &quot;photo.gif&quot;

and you will need to find out what you path is to set 'folder' to.

does that make sense ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top