1

If one file is used by other process and you are trying to manipulate with it...it gives an error:-

The process cannot access the file 'abc.txt' because it is being used by another process.

In C#, How can i come to know that 'abc.txt' file is used by the process Name "XYZ.exe" (or any other process)?

Jango
  • 5,375
  • 14
  • 57
  • 63
  • 2
    What do you plan to do once you figure out what process is accessing it? – Anon. Feb 09 '10 at 20:41
  • My scheduled console application runs after every set of time. If, somehow the file 'abc.txt' is in use by other process (in this case XYZ.exe), i will stop the execution of my application and wait for next call. – Jango Feb 09 '10 at 20:46
  • 1
    Why do you need to know which process is accessing it? Just try to open the file for exclusive access, and if it fails, exit. – Anon. Feb 09 '10 at 20:56
  • Oh..so you mean try catch... ? – Jango Feb 09 '10 at 21:01

1 Answers1

1

I did a quick search and think these posts can be helpful to you:

Similar Question

C# Answer#1

C# Answer #2

Community
  • 1
  • 1
CrimsonX
  • 9,048
  • 9
  • 41
  • 52