Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
System.IO.IOException: The process cannot access the file 'F:\Final\IQM SAMPLE WORK - Copy\File3\dotnet.xlsx' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at System.Web.HttpPostedFileWrapper.SaveAs(String filename) at iqmsampleworks_project.Areas.admin.Controllers.adminController.import(HttpPostedFileBase file, HttpPostedFileBase file1) in f:\Final\IQM SAMPLE WORK - Copy\Areas\admin\Controllers\adminController.cs:line 69
Posted
Updated 19-Jan-14 18:07pm
v2
Comments
Sandeep Singh Shekhawat 17-Jan-14 0:36am    
This file already opened before uploading. Please close the file and then try to upload it. It is not an MVC issue.
sailaja12345672 17-Jan-14 0:42am    
im importing exel shhet once it works well while uploading and if a uploading second time it shoo close the file by codeong

The error means what it says. You've done some file processing and left the file open, instead of closing it. Make sure you call 'close' methods and use using blocks for things that impliment idisposable.
 
Share this answer
 
You'll need to allow permissions to overwrite the file or you need to give it a different name when you save it the second time.
 
Share this answer
 
Comments
Christian Graus 20-Jan-14 17:18pm    
Wrong. The error does not mean it can't overwrite, it means it's already in use. No amount of permissions will change that. You are right that having a different name would make it work, but it would not fix the underlying issue.
ZurdoDev 20-Jan-14 17:42pm    
Try it and you'll see.
Christian Graus 20-Jan-14 17:45pm    
You're saying if I don't have permission to access a file, the error will say 'the file is open in another process' ?
ZurdoDev 20-Jan-14 17:48pm    
No. The other process is IIS. Of course neither of us actually know since there is not enough information so settle down a little bit.
Christian Graus 20-Jan-14 17:51pm    
Well, the fact is, I've seen this error, and it's NEVER been permissions, it's always been a handle left open. I am interested to know why you feel it could be anything else, because I've never seen a case where it was.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900