I have an aspx webpage that uses as handler to save uploaded files via swfupload I am saving the file on the server like this:
HttpPostedFile uploadedFile = Request.Files["Filedata"];
uploadedFile.SaveAs(LocationOnServer);
the problem is that after I save the file the file remain locked (by w3wp.exe) until I restart the IIS. Is there any way to release the file after save? Thanks
I have dealt with the same situation in the past. You need to run your application pool under a domain account. That is, the app pool under which your web application is running should be setup to run as a domain user. That same domain user should then be given permissions to the folder you are trying to upload to. In order to assign a domain user to your application pool, select the appropriate pool from the application pools node in IIS, right click and select properties. From the properties dialog box select the identity tab and choose "Configurable" and then provide a domain account. Then you should give permissions to the same user on your folder.
I cannot find any documentation but you might have to dispose of the HttpPostedFile object. Most of the time, if files are locked, then some object that associates with them has not been properly disposed.
Did you try calling Finalize() on it? Do you have any anti-virus or backup software that might be trying to grab the file?
I don't think permissions is the problem because if you didn't already have permissions to that folder you couldn't write the file to it in the first place.
I would check the folder permissions on the server. I had a similar issue where the application was able to create the file but not write to it, which caused it to lock up.