开发者

How to read and see the Binary file

开发者 https://www.devze.com 2023-02-18 02:21 出处:网络
This is what my code looks like: System.IO.BinaryWriter output; System.IO.TextReader input; System.IO.FileStream fs = new

This is what my code looks like:

System.IO.BinaryWriter output;
System.IO.TextReader input;
System.IO.FileStream fs = new
System.IO.FileStream(this.txtOutputFileName.Text, System.IO.FileMode.Create);
output = new System.IO.BinaryWriter(fs);
input = System.IO.File.OpenText(this.txtSourceFileName.Text);
string SourceProgram = input.ReadToEnd();
input.Close();
output.Write('B');
output.Write('3');
output.Write('2');

Now i would like to print the values written using the MessageBox.Show() Method. If i create an object say System.IO.BinaryReader readoutput - how do i go abou开发者_如何学编程t achieving my task??

Remember i simply want to verify 'B', '3', '2' are being written properly.


Call output.Close() and then open/read that file the same way you do here with 'input' and 'SourceProgram'


you could try the BinaryReader this way:

output.Close();

var readStream = new FileStream(this.txtOutputFileName.Text, FileMode.Open);

BinaryReader readBinary = new BinaryReader(readStream);

var msg = readBinary.ReadString();

MessageBox.Show(msg);

readStream.Close();
0

精彩评论

暂无评论...
验证码 换一张
取 消