タイトル : Re: バイナリデータ書き込み 投稿日 : 2006/11/18(Sat) 14:29 投稿者 : Occ
すみません。自己解決しました。 btBuffer = Byte.Parse(CInt("&H02").ToString()) w.Write(btBuffer ) 以上でバイナリエディタでみると「02」と表現されている文字の書き込みできました。 > バイナリデータの書き込みで質問があります。 > > まず、ヘルプファイルを参照すると、以下のサンプルがありました。 > ------------------------------------------------ > Option Explicit On > Option Strict On > Imports System > Imports System.IO > Class MyStream > Private Const FILE_NAME As String = "Test.data" > Public Shared Sub Main() > ' Create the new, empty data file. > If File.Exists(FILE_NAME) Then > Console.WriteLine("{0} already exists!", FILE_NAME) > Return > End If > Dim fs As New FileStream(FILE_NAME, FileMode.CreateNew) > ' Create the writer for data. > Dim w As New BinaryWriter(fs) > ' Write data to Test.data. > Dim i As Integer > For i = 0 To 10 > w.Write(CInt(i)) > Next i > w.Close() > fs.Close() > ' Create the reader for data. > fs = New FileStream(FILE_NAME, FileMode.Open, FileAccess.Read) > Dim r As New BinaryReader(fs) > ' Read data from Test.data. > For i = 0 To 10 > Console.WriteLine(r.ReadInt32()) > Next i > w.Close() > End Sub > End Class > ------------------------------------------------ > > バイナリデータの書き込みは上記の「w.Write(CInt(i))」で出来るのはわかったのですが、 > 困った分からない事があります。 > 「1」という数字を書き込み、バイナリエディタでみると、「31」と表現されています。 > これは、問題ないのですが、バイナリエディタでみると「02」と表現されている文字は > どのように書き込めばいいのでしょうか? > > 質問内容がうまくまとまらず、内容が分かりにくいかも知れませんが、 > よろしくお願い致します。 |