为什么我在运行IIS服务器中安装的Windows服务时无法将Excel文件从源文件夹移动到目标文件夹? [英] Why I am unable to move an Excel file from source folder to destination folder when running a windows service installed in IIS server?

查看:121
本文介绍了为什么我在运行IIS服务器中安装的Windows服务时无法将Excel文件从源文件夹移动到目标文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在运行IIS服务器中安装的Windows服务时,我无法将Excel文件从源文件夹移动到d

estination文件夹? Excel文件数据正在插入,状态也正在改变,但excel文件没有移动。它偶尔发生。我收到一条错误消息文件被另一个进程使用我正在使用带有c#的asp.net和IIS 7.5。



代码如下:



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:

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);


                   }

推荐答案

这个异常可能是由资源(如与您正在尝试移动的文件关联的流,XLS应用程序对象等)尚未由您正在使用的服务发布。
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.


这篇关于为什么我在运行IIS服务器中安装的Windows服务时无法将Excel文件从源文件夹移动到目标文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆