2015年3月26日木曜日

readfile writefile

using System.IO; //ファイルを読み込む
private string readfile(string h_fname)
{
StreamReader sr = new StreamReader(
h_fname, Encoding.GetEncoding("Shift_JIS"));

string text = sr.ReadToEnd();

sr.Close();
return text;
}

//ファイルを書き込む
private void writefile(string h_fname,string h_data)
{
Encoding sjisEnc = Encoding.GetEncoding("Shift_JIS");
StreamWriter writer =
new StreamWriter(h_fname, false, sjisEnc);
writer.Write(h_data);
writer.Close();
}

0 件のコメント:

コメントを投稿