Click here to Skip to main content
14,970,515 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
am getting exception that
[System.IO.IOException] = {"The process cannot access the file 'D:\\SerialNumberBasedReport 8-6-2012.xls' because it is being used by another process."}

This file is opened.
when am trying to delete this file through code in c#.
How to find whether file is opened or not in C#.
Updated 8-Jun-16 19:45pm

Yes, The exception is obvious, Because you file(D:\\SerialNumberBasedReport 8-6-2012.xls) is already open in MS Excel or some other application might be using it. Try closing the file to ignore the exception.

Thank you for your reply.
In this i want to whether file is opened or to find file is opened or not.
_Amy 6-Aug-12 3:02am
Catch your System.IO.IOException using try catch block and show the alert message to user in catch block. :)
thanks Amit
AshishChaudha 6-Aug-12 3:11am
my 5! amit
_Amy 6-Aug-12 3:14am
Thank you Ashish. :)
Dhasarathan T 20-Sep-14 9:40am

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