Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Why I am unable to move an Excel file from source folder to d
estination folder when running a windows service installed in IIS server? Excel file data is getting inserted and also the status is changing fine but the excel file is not moving.It happens occassionally.I am getting an error message as "File is being used by another Process" I am using asp.net with c# and IIS 7.5.

code as follows:

C#
m_ExcelClient.openConnection();

--Then fetching of data from excel and afterwards below code.

try
                   {
                       if (m_ExcelClient != null)
                       {
                           m_ExcelClient.closeConnection();
                           m_ExcelClient = null;
                       }
                       GC.Collect();
                       File.Move(FilePath, CopyDestinationPath);
                   }
                   catch (Exception ex)
                   {
                       Common.WriteTextFile(ErrorLogPath, ex.Message);


                   }
Posted
Updated 21-May-14 18:54pm
v2

1 solution

This exception could be generated by the fact that the resources (like streams, XLS Application object, etc.) associated with the file that you are trying to move were not yet released by the service that you are using.
 
Share this answer
 

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