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

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
 
P

Patrice

Connection pooling get in the way ? Try perhaps to disable connection
pooling in the query string to see if it helps...

Patrice
 
V

vMike

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top