TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chris
NA
20
0
Binary Reader Help
Jan 4 2009 4:32 PM
Hi, I am making a Binary Reader find then read a string and input it into a textbox. I have 2 questions. I need to search for a string and read the string a byte afterwards. The string I am reading can be 1 - 4 bytes long. It is offset between "". (Two quotes [it is inside])
1) Is there a way I can make it find a string faster because right now on large files it just locks up.
2) What is wrong with this code, I keep catching these errors.
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "All Files|*.*";
ofd.Title = "Open Profile";
ofd.FileName = "";
if (ofd.ShowDialog() == DialogResult.OK)
fileLocation = ofd.FileName;
//Searches for the clan tag
string search = "clanName ";
BinaryReader br = new BinaryReader(new FileStream(fileLocation, FileMode.Open, FileAccess.Read));
// Starting offset
br.BaseStream.Position = 0x14000;
string found = "";
try
{
// read next 65536 chars
found = new string(br.ReadChars(0x10000));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
// Find our starting position in buffer
int index = found.IndexOf(search);
textBox1.Text = found.Substring(index, 20);
}
Reply
Answers (
3
)
how to debug BHO?
Number of client connections