文件名称:common文本读写
文件大小:1KB
文件格式:TXT
更新时间:2018-08-02 10:03:20
txt读写
对记事本文件的读写c# 1.Readtxt public static string[] ReadTxt(string sPath, string sFileName) { string txtPath = sPath + "\\" + sFileName; StreamReader textFile = null; if (File.Exists(txtPath)) { textFile = new StreamReader(txtPath, Encoding.GetEncoding("gb2312")); } string[] result; if (textFile != null) { char[] sp = new char[] { '\r', '\n' }; string tValues = textFile.ReadToEnd(); string[] sContent2 = tValues.Split(sp, StringSplitOptions.RemoveEmptyEntries); textFile.Close(); result = sContent2; } else { result = null; } return result; }