Click here to Skip to main content
15,898,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, all!

I want to let this programme create a text file to store data.
The text file can be created, but the data became square blocks when displayed in PDA.

How do I solve this problem, please advise.

VB
Dim Info(5) As Byte
SerialPort1.Read(Info, 0, 5)

TextBox1.Text = Info(0)
TextBox2.Text = Info(1)
TextBox3.Text = Info(2)
TextBox4.Text = Info(3)

Dim FS As FileStream
FS = New FileStream("\My Documents\test.txt", FileMode.Append, FileAccess.Write)

FS.Write(Info, 0, Info.Length)
FS.Close()


Thx in advance!
Posted
Updated 26-Oct-10 22:47pm
v2
Comments
Dalek Dave 27-Oct-10 4:48am    
Edited for Grammar.

Use the Binary Writer Instead of Stream Writer.., Because SerialPort can read Binary Data Also..,

Here is the code for write Binary file using the byte array

byte[] temp = new byte[100];
  FileStream fs = new FileStream("c:\\temp.txt", FileMode.Create);
  BinaryWriter Bw = new BinaryWriter(fs);
  Bw.Write(temp);
  Bw.Close();
  fs.Close ();
 
Share this answer
 
Thx for reply!
I tried BinaryWriter, but it has the same result as StreamWriter, number array into the textfile still showed as blocks.
So i changed my direction ha. I just use all the textboxes as my 'data source' instead of Bytes.
Now it can work! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900