I have this code for reading from a Stream
:
OpenFileDialog op = new OpenFileDialog();
op.ShowDialog();
Stream stream = File.Open(op.FileName,FileMode.Open);
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, 10); // Problem is in this line
MessageBox.Show(System.Text.Encoding.UTF8.GetString(bytes));
This code works, but if I change the zero in the marked line then the MessageBox
doesn't show anything.
How can I resolve this problem?