File is used by another process?
- by Surya sasidhar
I get this error (file is being used by another process).
Actually I write the code in a button click event like this, i am saving the excel file in a file using file upload, immediately i am fetching the file which i was save just now there i am getting this error. in my point of view i think it take time to save the excel file in that file. this is my code:
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/User/Excel/" + name.ToString() + ".xls"));
string s = Server.MapPath("~/user/excel/" + name.ToString() + ".xls");
OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + s.ToString() + ";" + "Extended Properties=\"Excel 8.0;HDR=Yes\"");
DBConnection.Open();
string SQLString = "SELECT * FROM Contacts";
OleDbCommand DBCommand = new OleDbCommand(SQLString, DBConnection);
IDataReader DBReader = DBCommand.ExecuteReader();
mygridOut.DataSource = DBReader;
mygridOut.DataBind();
and i am getting error like this:
because it is being used by another process.