Click to See Complete Forum and Search --> : How do I delete a file?


Danbabe
08-11-2006, 04:35 PM
Hi Guys,

I have members who have all of their records ina database. The records relate to Photos that they have stored in their personal folders.

If they delete a Photo, the database entry, I can delete fine but how do you delete the actual physical file in their folder?

I would guess at a real stabb that somehow you would use Server.CreateObject("Scripting.FileSystemObject") but dont know the actual code even if I am correct.

Thanks for looking

Dan

russell
08-11-2006, 09:30 PM
Right you are

Dim fso

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

fso.DeleteFile "c:\xxx\yyy\myFile.zzz"

to force it to delete even if read only

fso.DeleteFile "c:\xxx\yyy\myFile.zzz", true

ejrhodes
08-15-2006, 12:47 PM
We do something similar on a website I am working on right now. We store the displaynam e (the name of the file once it gets downloaded) and the actual storedname(displayname plus timestamp) in our DB. When we delete the file from the db, we pass the storedname from the recordset to the deletefile command above. Works pretty well.