LoginSignup
2
2

More than 5 years have passed since last update.

ファイル操作

Posted at

テキストファイルの入力

1行ずつ読み込む

StreamReaderクラスを使って、テキストファイルを読み込む。

C#プログラミングTips ファイル入出力の基礎
http://www.atmarkit.co.jp/fdotnet/csharptips/005file/005file.html

一気に読み込む

FileクラスのReadAllLines静的メソッドを使って、テキストファイルを読み込む。
.NET Framework4以上では、IEnumerableを返すReadLines静的メソッドを使える。

テキストファイルへの出力

1行ずつ書き込む

StreamWriterクラスを使って、テキストファイルへ書き込む。

一気に書き込む

FileクラスのWtiteAllLines静的メソッドを使う。
.NET Framework4以上では、IEnumerableを引数で受け取れるWriteAllLines静的メソッドも使える。

2
2
0

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
2
2