FileStream aFile = new FileStream(SingleFile, FileMode.Open); StreamReader sr = new StreamReader(aFile, Encoding.GetEncoding("gb2312"), true); string FileContent = sr.ReadToEnd(); aFile.Close(); ProcessData Pd = new ProcessData(); Pd.ProceData(FileContent);
StreamReader 使用3個參數 最後一個自動偵測utf-8,中文大部分是gb2312,如果不是utf-8,就用gb2312
系統自帶utf 檢測 ,見如下