+ 2

How to write real time data to binary file

Hi, I have real time data from usb (serial comunication) and I need to write these data to binary file every time that I press a rec button and then save it. I'm a beginner in c#. Thanks to everyone, and sorry if my english is not good.

11th Mar 2019, 10:43 AM
Valerio Carvani
Valerio Carvani - avatar
3 Réponses
+ 1
Use a file stream. You can save a lot of different data_types in there. This example uses. Memorystream. private void button1_Click(object sender, EventArgs e) { string memString = "Memory test string !!"; // convert string to stream byte[] buffer = Encoding.ASCII.GetBytes(memString); MemoryStream ms = new MemoryStream(buffer); //write to file FileStream file = new FileStream("d:\\file.txt", FileMode.Create, FileAccess.Write); ms.WriteTo(file); file.Close(); ms.Close(); } http://net-informations.com/q/faq/memory.html
11th Mar 2019, 9:37 PM
sneeze
sneeze - avatar
+ 1
Thanks for the reply. It seems simple; I'll study how file stream works and I'll try.
11th Mar 2019, 9:56 PM
Valerio Carvani
Valerio Carvani - avatar
0
pql
12th Mar 2019, 7:51 AM
이강이
이강이 - avatar