Click here to Skip to main content
15,843,137 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi there, i have a .dat file which contain data, and i want to send this data through serial port rs232 communication. i use compact framework visula studio 2008,C#.
i have no idea how to send the data that is inside file .dat

thanks:)

What I have tried:

Hi there, i have a .dat file which contain data, and i want to send this data through serial port rs232 communication. i use compact framework visula studio 2008,C#.
i have no idea how to send the daya that is inside file .dat

thanks:)
Posted
Updated 6-Jun-16 2:48am
v2
Comments
Richard MacCutchan 5-Jun-16 11:25am    
And why do you think anyone here will know? We have no idea what the contents of that file are, or what you expect when you send it out through the serial port.

Please edit your question and really show what you have tried, and explain any problem(s) you encountered.

1 solution

Create a SerialPort instance: SerialPort Class (System.IO.Ports)[^], set the interface parameters correctly so they match the equipment at the otehr end (the link includes an example) and open it.
Then read the file and send it:
C#
byte[] data = File.ReadAllBytes(pathToDATFile);
mySerialPort.Write(data, 0, data.Length);
 
Share this answer
 
Comments
OriginalGriff 6-Jun-16 8:17am    
Then use a StreamReader and the Read method.

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