delete file failed, The process cannot access the file because it is being used by another process

  • Thread starter Thread starter guoqi zheng
  • Start date Start date
G

guoqi zheng

Dear sir,

There is an import tool on my web application, user can upload Ms Access
file, the file is saved at a temp folder on the server. After the import is
finished, for security reason, I need to delete the imported Ms Access file,
however, I always get above error, "The process cannot access the file
because it is being used by another process"

I did close the datareader and connection object. What else can I do to
delete this file???????

regards,

Guoqi Zheng
http://www.ureader.com
 
Connection pooling get in the way ? Try perhaps to disable connection
pooling in the query string to see if it helps...

Patrice
 
guoqi zheng said:
Dear sir,

There is an import tool on my web application, user can upload Ms Access
file, the file is saved at a temp folder on the server. After the import is
finished, for security reason, I need to delete the imported Ms Access file,
however, I always get above error, "The process cannot access the file
because it is being used by another process"

I did close the datareader and connection object. What else can I do to
delete this file???????

regards,

Guoqi Zheng
http://www.ureader.com

Make sure you also close the stream that holds the imported file once you
have written it out. (assuming that is how your are writing to the temp
folder). If you open the temp file to copy it or move it, make sure you are
closing that too. File operations are not managed by .net in many cases.
 
Back
Top