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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlWriter.WriteBase64 メソッドの意味・解説 

XmlWriter.WriteBase64 メソッド

派生クラスオーバーライドされると、指定したバイナリ バイトBase64 としてエンコードし、その結果生成されるテキスト書き込みます

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

例外例外
例外種類条件

ArgumentNullException

buffernull 参照 (Visual Basic では Nothing) です。

ArgumentException

バッファ長から index差し引いた値が count より小さい値です。

ArgumentOutOfRangeException

index または count が 0 未満です。

解説解説
使用例使用例

WriteBase64 メソッド使用してBase64 データ書き込む例を次に示しますBase64 データは、<image> 要素内に埋め込まれます。

Public Shared Sub Base64EncodeImageFile()
 
    
    Dim bufferSize As Integer
 = 1000
    Dim buffer(bufferSize) As Byte
    Dim readBytes As Integer
 = 0
    
    Using writer As XmlWriter = XmlWriter.Create("output.xml")

            Dim inputFile As New
 FileStream("C:\artFiles\sunset.jpg", FileMode.OpenOrCreate,
 FileAccess.Read, FileShare.Read)
            writer.WriteStartDocument()
            writer.WriteStartElement("image")
            Dim br As New
 BinaryReader(inputFile)
            Console.WriteLine(vbCr + vbLf + "Writing Base64 data...")
            
            Do
                readBytes = br.Read(buffer, 0, bufferSize)
                writer.WriteBase64(buffer, 0, readBytes)
            Loop While bufferSize <= readBytes
            br.Close()
        
        writer.WriteEndElement() ' </image>
        writer.WriteEndDocument()

    End Using
 
End Sub 'Base64EncodeImageFile

public static void Base64EncodeImageFile()
 {

  int bufferSize = 1000;
  byte[] buffer = new byte[bufferSize];
  int readBytes = 0;
    
  using (XmlWriter writer = XmlWriter.Create("output.xml"))
 {

       FileStream inputFile = new FileStream(@"C:\artFiles\sunset.jpg"
,
                                                                    FileMode.OpenOrCreate,
 FileAccess.Read, FileShare.Read);
       writer.WriteStartDocument();
       writer.WriteStartElement("image");
       BinaryReader br = new BinaryReader(inputFile);
       Console.WriteLine("\r\nWriting Base64 data...");

       do {
          readBytes = br.Read(buffer, 0, bufferSize);
          writer.WriteBase64(buffer, 0, readBytes);
       } while (bufferSize <= readBytes);
       br.Close();
        
    writer.WriteEndElement();// </image>
    writer.WriteEndDocument();
        
  }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

XmlWriter.WriteBase64 メソッドのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS