Debug.Flush メソッドとは? わかりやすく解説

Debug.Flush メソッド

出力バッファフラッシュし、バッファ内のデータListeners コレクション書き込みます

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

<ConditionalAttribute("DEBUG")> _
Public Shared Sub Flush
Debug.Flush
[ConditionalAttribute("DEBUG")] 
public static void Flush
 ()
[ConditionalAttribute(L"DEBUG")] 
public:
static void Flush ()
/** @attribute ConditionalAttribute("DEBUG") */ 
public static void Flush
 ()
ConditionalAttribute("DEBUG") 
public static function Flush
 ()
解説解説

ストリームフラッシュしても、Flush または Close明示的に呼び出さない限り、そのストリームの基になるエンコーダフラッシュされません。AutoFlush を true設定すると、データバッファからストリームフラッシュされますが、エンコーダの状態はフラッシュされません。これにより、エンコーダの状態 (一部文字) を維持できるため、次のブロック文字正確にエンコードできるようになります。この動作は、一部文字エンコードするためにはエンコーダがあらかじめその文字隣接する文字受け取っておく必要がある UTF8 および UTF7 に対して有効です。

使用例使用例

myTextListener という名前の TextWriterTraceListener を作成する例を次に示しますmyTextListener は、myOutputWriter という名前の StreamWriter を使用してTestFile.txt というファイル書き込みます。この例では、ファイルストリーム、およびテキスト ライタ作成しテキストの 1 行をファイル書き込んでから、出力フラッシュして終了します

Overloads  Shared Sub Main(args()
 As String)
    ' Create a file for output named TestFile.txt.
    Dim myFileName As String
 = "TestFile.txt"
    If Not File.Exists(myFileName) Then
        File.Create(myFileName)
    End If 
    
    ' Assign output file to output stream.
    Dim myOutputWriter As StreamWriter
    myOutputWriter = File.AppendText(myFileName)
    
    ' Create a new text writer using the output stream, and
    ' add it to the trace listeners. 
    Dim myTextListener As New
 TextWriterTraceListener(myOutputWriter)
    Debug.Listeners.Add(myTextListener)
    
    ' Write output to the file.
    Debug.WriteLine("Test output")
    
    ' Flush and close the output stream.
    Debug.Flush()
    Debug.Close()
End Sub 'Main
static void Main(string[]
 args) {
    // Create a file for output named TestFile.txt.
    String myFileName = "TestFile.txt";
    if(!File.Exists(myFileName)) 
    File.Create(myFileName);

 
    // Assign output file to output stream.
    StreamWriter myOutputWriter;
    myOutputWriter = File.AppendText(myFileName);
 
    /* Create a new text writer using the output
 stream, and 
     * add it to the trace listeners. */
    TextWriterTraceListener myTextListener = new 
       TextWriterTraceListener(myOutputWriter);
    Debug.Listeners.Add(myTextListener);
  
    // Write output to the file.
    Debug.WriteLine("Test output");
 
    // Flush and close the output stream.
    Debug.Flush();
    Debug.Close();
 }

#using <System.dll>

using namespace System;
using namespace System::IO;
using namespace System::Diagnostics;
int main( void )
{
   
   // Create a file for output named TestFile.txt.
   String^ myFileName = "TestFile.txt";
   if (  !File::Exists( myFileName ) )
      File::Create( myFileName );

   
   // Assign output file to output stream.
   StreamWriter^ myOutputWriter;
   myOutputWriter = File::AppendText( myFileName );
   
   /* Create a new text writer using the output
 stream, and 
        * add it to the trace listeners. */
   TextWriterTraceListener^ myTextListener = gcnew TextWriterTraceListener( myOutputWriter
 );
   Debug::Listeners->Add( myTextListener );
   
   // Write output to the file.
   Debug::WriteLine( "Test output" );
   
   // Flush and close the output stream.
   Debug::Flush();
   Debug::Close();
}

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Debug クラス
Debug メンバ
System.Diagnostics 名前空間
Debug クラス
Trace
BooleanSwitch クラス
TraceSwitch
TraceListener
DefaultTraceListener
ConsoleTraceListener クラス
ConditionalAttribute クラス


このページでは「.NET Framework クラス ライブラリ リファレンス」からDebug.Flush メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDebug.Flush メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDebug.Flush メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  
  •  Debug.Flush メソッドのページへのリンク

辞書ショートカット

すべての辞書の索引

検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Debug.Flush メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS