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();
精彩评论