views:

618

answers:

5

I'm using asp:FileUpload control to upload a file to the server. Nothing fancy there, just

FileUploadId.Save();

File gets uploaded successfully, and everything is fine until I try to delete that file on the CLIENT. I get a good-old "File is being used by another person or program" message.

How do I make sure that file is not being accessed on the client after it's been uploaded?

EDIT

deleting the file has nothing to do with the application. i'm just trying to delete the file manually since i don't need it any more.

EDIT2

closing the browser fixed the problem ... any ideas?

A: 

How are you trying to delete the file at the client? Unless you're hosting in WebBrowser, or using something like an ActiveX control, you only have javascript at the client - and that doesn't provide random file access.

So: what is the full setup here?

Marc Gravell
I'm deleting it MANUALLY, deleting part has nothing to do with the APP. i have the file (abc.zip), i upload it to the server, i delete abc.zip locally, since i don't need it any more ... oops ... can't delete
roman m
So... at best there is a bug in the browser. Not sure that we can help with that...
Marc Gravell
A: 

A thought. It may not be the file upload that is causing the problem. As the surrounding code isn't posted it's difficult to tell, but, for example, do you have a Zip manager object of some kind that you're not disposing of?

dommer
+1  A: 

Since the problem happens both in IE and FF: could it be that the file is locked by some AntiVirus software?

M4N
If I remember correctly I had the same problem on a machine with AVG installed...
Kalmi
A: 

The issue might be the file can be locked by the aspnet process even after uploading. Once you close the IE, the aspnet process release the file

Abbas
A: 

I have the same problem; I'm saving a file in the server, sending it as an attached file in a e-mail message (using .net.mail). The e-mail sends succesfully, but when I try to delete the file posted with the FileUpload control it says me that the file cannot be deleted because there's another proccess using it.

I'm using Firefox (not IE), I've rebooted my PC but it doesn't works. Additionally, I'm using the next code to "release" the data stream, but it doesn't works:

FileUpload1.SaveAs(filename) 'here I save the posted file

FileUpload1.PostedFile.InputStream.Dispose() 'this is for release the stream, but doesn't works

Any suggestions?

Thanks!

Luis Fernando
Ok, I solved my issue. As I said, I'm sending the posted file as an attached file; but I wasn't disposing the MailMessage object after sending it. I just added the next code before deleting the file: Message.Dispose() 'Message is an instanced object of the Mail.Message ClassSystem.IO.File.Delete(filename)Hope this helps anyone with the same problem. See ya.
Luis Fernando