Any difference between File.ReadAllText() and using a StreamReader to read file contents?

后端 未结 4 1045
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 03:35

At first I used a StreamReader to read text from a file:

StreamReader reader = new StreamReader(dialog.OpenFile());
txtEditor.Text = reader.Read         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 04:15

    If you use File.ReadAllText to read an unmanaged logging file (control by fstream), call File.ReadAllText, there will have IO.Exception:

    The file is control by another process

    You must to use StreamReader ReadToEnd to replace it.

提交回复
热议问题