次の方法で共有


StringWriter.Write メソッド (Char , Int32, Int32)

StringWriter のインスタンスに文字配列の指定した領域を書き込みます。

Overrides Overloads Public Sub Write( _
   ByVal buffer() As Char, _   ByVal index As Integer, _   ByVal count As Integer _)
[C#]
public override void Write(char[] buffer,intindex,intcount);
[C++]
public: void Write(__wchar_tbuffer __gc[],intindex,intcount);
[JScript]
public override function Write(
   buffer : Char[],index : int,count : int);

パラメータ

  • buffer
    データの読み取り元の文字配列。
  • index
    読み取りの開始位置を示す buffer 内のインデックス。
  • count
    書き込む文字の最大数。

例外

例外の種類 条件
ArgumentNullException buffer が null 参照 (Visual Basic では Nothing) です。
ArgumentOutOfRangeException index または count が負の値です。
ArgumentException (index + count)> buffer. Length.
ObjectDisposedException ライタが閉じています。

解説

このメソッドは、 TextWriter.Write をオーバーライドします。

このメソッドは、 index を開始位置として、 buffer 文字配列からのこの StringWriter にデータの count 文字を書き込みます。

その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。

実行するタスク 参考例があるトピック
テキスト ファイルを作成する。 ファイルへのテキストの書き込み
テキスト ファイルに書き込む。 ファイルへのテキストの書き込み
テキスト ファイルから読み取る。 ファイルからのテキストの読み取り
テキストをファイルに追加する。 ログ ファイルのオープンと追加

File.AppendText

FileInfo.AppendText

ファイルのサイズを取得する。 FileInfo.Length
ファイルの属性を取得する。 File.GetAttributes
ファイルの属性を設定する。 File.SetAttributes
ファイルが存在するかどうかを判別する。 File.Exists
バイナリ ファイルから読み取る。 新しく作成したデータ ファイルの読み取りと書き込み
バイナリ ファイルに書き込む。 新しく作成したデータ ファイルの読み取りと書き込み

使用例

[Visual Basic, C#, C++] 次のコード例は、 System.IO.StringWriter.StringWriter コンストラクタの例の一部です。

 
' Use the three overloads of the Write method that are 
' overridden by the StringWriter class.
strWriter.Write("file path characters are: ")
strWriter.Write( _
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length)
strWriter.Write("."C)

[C#] 
// Use the three overloads of the Write method that are 
// overridden by the StringWriter class.
strWriter.Write("file path characters are: ");
strWriter.Write(
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
strWriter.Write('.');

[C++] 
// Use the three overloads of the Write method that are 
// overridden by the StringWriter class.
strWriter->Write(S"file path characters are: ");
strWriter->Write(
    Path::InvalidPathChars, 0, Path::InvalidPathChars->Length);
strWriter->Write(Char::Parse(S"."));

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

StringWriter クラス | StringWriter メンバ | System.IO 名前空間 | StringWriter.Write オーバーロードの一覧 | 入出力操作 | ファイルからのテキストの読み取り | ファイルへのテキストの書き込み