c# - Open File Which is already open in window explorer -


i trying open file using openfiledialog.

if (openfiledialog1.filename != "" && resultsavedialog == system.windows.forms.dialogresult.ok)         {             openfiledialog1.openfile(); // throw exception here             txtfilename.text = openfiledialog1.safefilename;                         } 

but if file opened in window explored throws me following exception

the process cannot access file 'd:\projects\cdr_raw_files\groupdata\8859511378.xls' because being used process.

is possible open file using openfiledialog if file has opened in window explorer.

ok, if need selected file name , path, try below, you...

if (openfiledialog1.filename != "" && resultsavedialog == system.windows.forms.dialogresult.ok) {  string path = path.getdirectoryname(openfiledialog1.filename);  string filename = path.getfilename(openfiledialog1.filename);  txtfilename.text = filename; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -