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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete files

Status
Not open for further replies.

b00gieman

Programmer
Jul 9, 2007
60
DE
Hi!
I developed a com+ component for sending emails with multiple attachments.The uploaded files are stored on a directory and after the email is send, they are supposed to be deleted.The only problem is that the files aren't deleted.The code looks like this:
Code:
Set oFolder = oFSO.GetFolder(sFolder)
                  For Each oFile In oFolder.Files
                      If InStr(oFile.Name, "_" & user) > 0 Then
                                     oMail.AddAttachment oFile.Path
                                     FileSize = Format((FileLen(oFile) / 1024) / 1024)
                                     SumSize = SumSize + FileSize
                                     oFSO.DeleteFile (oFile)
                      End If
                  Next

What do I do wrong?
 
Does it make an error?

If your page has On Error Resume Next try commenting it out briefly and see if you get an error message. The error message will point to the problem.
 
No...The problem is that after the files are sent,if I check the folder where they are supposed to be temporarily stored,the files are still there...if I try to open any file,I get 'access denied'...deleting them is not possible either...
 
Perhaps the oMail has a lock on the files that prevents them being deleted... Try moving the call to DeleteFile to the bottom of the script, so it runs after the mail is actually sent.

It seems like the DeleteFile should give the same access denied error.
 
Maybe I could just upload the files and send them,and then sepparately run a script for deleting the files...
 
NWS:I checked the file properties.Usually , each file has the "Security" and "Summary" options,but the files in that folder do not have these options.Any idea why?
 
Is the ASP running with anonymous access? Perhaps the default IUSR_<MachineName> doesn't have permissions on the file.
 
I also created a script that deletes the files.The script doesn't generate any error,but when I check the folder,nothing's changed....
 
I also created a script that deletes the files.

Do you mean a .VBS file? If so, if you log into the work server as administrator and run the file it still doesn't work? Are these files local to the web server? Are they in a folder below \inetpub\ ?
 
the script is done in asp.However,I have the permission to delete files from the asp application.However,if I check the directory the next day,the files aren't there anymore,so I'm thinking it might be a 'lock' done by the application....
 
if I check the directory the next day,the files aren't there anymore,so I'm thinking it might be a 'lock' done by the application

Are you sure it they aren't deleted right away and its not just that the screen needs to be refreshed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top