Will a using clause close this stream?

后端 未结 5 1265
难免孤独
难免孤独 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:44

    I would try to use FileInfo.Open() and FileInfo.MoveTo() instead of File.Open() and File.Move(). You could also try to use FileInfo.OpenText(). But these are just suggestions.

提交回复
热议问题