3
找了幾個星期後,我似乎找不到解決我的問題的方法。我想要做的是用RichTextBox打開一個表單,按一個加載按鈕並加載一個要搜索的文件。然後,有一個單選按鈕在RichTextBox中選擇jpeg
或bmp
&,顯示所有jpeg或bmp的 - 不是圖像,只是偏移位置。在.bin文件中找到bmp
例如,「在0x00002311找到的jpg」是開始的偏移量,或「在0x00009382找到的bmp」巫婆是BM在選定的.bin
文件中開始的位置。
這是我在哪裏:它找到一個bmp
或jpeg
並顯示計數,但不顯示偏移量。我需要它來查找所有圖像和偏移量。
private void button7_Click(object sender, EventArgs e)
{
using (OpenFileDialog dlgOpen = new OpenFileDialog())
{
try
{
long count = 0; string line;
List<String> LinesFound = new List<string>();
dlgOpen.Filter = "All files(*.*)|*.*";
dlgOpen.InitialDirectory = "C://bin";
dlgOpen.Title = "Load";
if (dlgOpen.ShowDialog() == DialogResult.OK)
textBox5.Text = dlgOpen.FileName;
{
var sr = new StreamReader(dlgOpen.FileName, Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
if (line.Contains("ÿØÿà"))
richTextBox1.Text = ("JPEG Found at address") + count++;
else if (line.Contains("BM"))
richTextBox1.Text = ("BMP Found at address") + count++;
}
}
}
catch (Exception)
{
MessageBox.Show("error in reading file");
}
}
}
是您的實際代碼?你有錯誤的地方。它甚至沒有編譯。 –
我刪除了一些「if(line.Contains(」「))。縮短帖子。如果你從底部刪除1}並且在catch上添加一個}應該可以。 – DARCOM8
你可以編輯問題到自己解決它。 –