Will a using clause close this stream?

后端 未结 5 1264
难免孤独
难免孤独 2020-12-20 10:55

I\'ve apparently worked myself into a bad coding habit. Here is an example of the code I\'ve been writing:

using(StreamReader sr = new StreamReader(File.Open         


        
5条回答
  •  臣服心动
    2020-12-20 11:34

    Is there any possibility that something else has a lock to somefile.txt?

    A simple check from a local (to the file) cmd line

    net files
    

    may well give you some clues if anything else has a lock.

    Alternatively you can get something like FileMon to take even more details, and check that your app is releasing properly.

提交回复
热议问题