1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[C#] ファイルの出力

Posted at

#ファイルの出力

FileInfo fi = new FileInfo(GlobalVariable.custom_csv_path);
using (StreamWriter sw = fi.AppendText())
{
sw.Write("OUTPUT SOMETHING");
}

usingが使いたくないなら、以下のように自分でcloseしなければいけないらしい。これは面倒だ。
usingを使うと、usingを抜ける際に自動的にやってくれるらしい。

FileInfo fi = new FileInfo(GlobalVariable.custom_csv_path);
StreamWriter sw = fi.AppendText();
sw.Write("OUTPUT SOMETHING");
sw.Flush();
sw.Close();
1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?