Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Posted
Comments
koolprasad2003 25-Aug-11 1:01am    
do you want to open EXCEL file in using web application right?
if yes then you can use javascript Window.Open().

1 solution

You have to check if you can open the file exclusively:

C#
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;
                   }
 
Share this answer
 
v3

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