I am very new to VB and I am using VB studio 2010 now. What I want to do is to receive data from another port and save it in my directory. However the port can receive my buffer from another port but could not save the file. The codes are as below:
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim string_data As String
Dim binary_data() As Byte
string_data = SerialPort1.ReadExisting
binary_data = System.Text.Encoding.ASCII.GetBytes(string_data)
SaveFile.ShowDialog()
Dim fs As IO.FileStream = New IO.FileStream(SaveFile.FileName, IO.FileMode.Create)
Dim bw As BinaryWriter = New IO.BinaryWriter(fs)
bw.Write(binary_data)
bw.Flush()
bw.Close()
fs.Close()
Thanks in advance
J