+ 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.
3 ответов
+ 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
+ 1
Thanks for the reply.
It seems simple; I'll study how file stream works and I'll try.
0
pql