Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
Reading a file byte by byte
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Sebastian Harko
17y
2.3k
1
Reply
Hello everyone,
I'm trying to do an hex editor in C#. My plan is to read a file byte by byte and display the byte in a text box.
I have the code bellow but it works very slow. Does anyone know why it works so slow ??
///
<summary>
///
Opens a file chooser.
///
</summary>
///
private
void
openToolStripMenuItem_Click(
object
sender,
EventArgs
e)
{
openFileDialog.ShowDialog();
string
fileName = openFileDialog.FileName;
FileStream
fileReader =
new
FileStream
(fileName,
FileMode
.Open,
FileAccess
.Read);
long
length = fileReader.Length;
long
position = 0;
while
(position < length){
position++;
textBox.Text += fileReader.ReadByte() +
" "
;
}
}
Best regards
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Absorbing Web Services
New and not sure what wrong here