File is being used by another process

后端 未结 7 1247
野的像风
野的像风 2021-01-11 21:08

I have a program that roughly does this:

  1. open a file to read from it.
  2. close the file
  3. Start a filewatcher to watch for changes in the file.
7条回答
  •  终归单人心
    2021-01-11 21:55

    There are a number of things that could be going on.

    First, make sure you properly dispose of the file writer (close isn't good enough) by utilizing the using clause around everything that implements IDisposable.

    Second, it you are simply reading, make sure you have the correct flags set when opening the file.

    To go any further it would help if you provided a code block which showed how you were accomplishing this; particularly around the reading of the file

提交回复
热议问题