带有EXCELDATA的excel文件已打开或不在网络中 [英] excel file with EXCELDATA is open or not in web
本文介绍了带有EXCELDATA的excel文件已打开或不在网络中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我正在使用VS 2005,asp.net,c#
如何检查在ASP.NET Web应用程序中是否打开了带有EXCELDATA的excel文件
在此先感谢
George
Hi friends,
I am using VS 2005,asp.net,c#
how to check whether an excel file with EXCELDATA is open or not in an asp.net webapplication
Thanks in advance
George
推荐答案
您必须检查是否可以单独打开文件:
You have to check if you can open the file exclusively:
FileStream stream = null;
bool isInUse = false;
try
{
// check if the file can be opened exclusive.
using (stream = File.Open(FolderAndFileName, FileMode.Open, FileAccess.Write, FileShare.None))
{
isInUse = !stream.CanWrite;
}
}
catch (Exception err)
{
isInUse = true;
}
这篇关于带有EXCELDATA的excel文件已打开或不在网络中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文