[C#] C#通过文件流读取文件内容 →→→→→进入此内容的聊天室

来自 , 2021-01-28, 写在 C#, 查看 134 次.
URL http://www.code666.cn/view/29000b02
  1. public static string getFileAsString(string fileName) {
  2.    StreamReader sReader = null;
  3.    string contents = null;
  4.    try {
  5.       FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
  6.       sReader = new StreamReader(fileStream);
  7.       contents = sReader.ReadToEnd();
  8.    } finally {
  9.      if(sReader != null) {
  10.          sReader.Close();
  11.       }
  12.    }
  13.    return contents;
  14. }
  15. //csharp/4809

回复 "C#通过文件流读取文件内容"

这儿你可以回复上面这条便签

captcha