リストビューを含むこのexeを作成したので、バイナリファイルを開くと、列にテキストポインターが表示され、別の列にテキスト文字列が表示されます。
「forループ」を使用してポインターを表示することができましたが、ループを使用してテキスト文字列を表示する方法がわからなかったので、使用したいのは、ポインターをループして、それが指すテキストを表示することですまで、各テキストの後に 00 00 で停止します。
これはバイナリファイル構造のサンプルです。
バイナリ ファイルの最初の 4 バイトはポインタ/文字列の量、次の 4 バイト * 最初の 4 バイトはポインタ、残りはテキスト文字列で、各文字列は 00 00 で区切られ、すべて Unicode です。
それで、文字列列の各ポインタの文字列を表示する方法について誰か助けてもらえますか?
編集:バイナリファイルを開くボタンのコードは次のとおりです。
private void menuItem8_Click(object sender, EventArgs e)
{
textBox1.Text = "";
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Open File";
ofd.Filter = "Data Files (*.dat)|*.dat|All Files (*.*)|*.*";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
MessageBox.Show("File opened Succesfully!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
path = ofd.FileName;
BinaryReader br = new BinaryReader(File.OpenRead(path));
int num_pointers = br.ReadInt32();
textBox1.Text = num_pointers.ToString();
for (int i = 0; i < num_pointers; i++)
{
br.BaseStream.Position = i * 4 + 4;
listView1.Items.Add(br.ReadUInt32().ToString("X"));
}
br.Close();
br = null;
}
ofd.Dispose();
ofd = null;
}