Tag: StreamReader
テキストファイルの読み込み
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public string OpenTextFile( string _filePath ){ FileInfo fi = new FileInfo(_filePath); string returnSt = ""; try { using (StreamReader sr = new StreamReader(fi.OpenRead(), Encoding.UTF8)){ returnSt = sr.ReadToEnd(); } } catch (Exception e){ print (e.Message); returnSt = "READ ERROR: " + _filePath; } return returnSt; } |
テキストファイルの書き込み(上書き)
1 2 3 4 5 6 |
public void WriteText( string _filePath, string _contents ){ StreamWriter sw; sw = new StreamWriter(_filePath, true); sw.WriteLine(_contents); sw.Close(); } |
&nbs…