Is there a way to check if a file is in use
> Here we consider Is there a way to check whether a file is in use in Asp.Net.
> Normally for updating the file in Asp.Net, it should not be used by any other task.
> So the first priority is to check whether the file is free to use.
> The best way to achieve this is to open the file within try catch block with read mode.
> While opening the file, if it is used by other thread, we will get the exception.
> This exception can be handled within catch block. An example is given below.

> Within exception block, we can return true since the file is in use.
> if we are not getting any Exception, we can return false.
> False means, the file is not used by any other process.
> By this way we can check
whether a file is in use or not.
Watch Video of this Content on Video Streaming