AyalaOrtiz
New member
- Joined
- Apr 8, 2023
- Messages
- 2
- Programming Experience
- Beginner
I am trying to create a file with the data that my Arduino sends me from a graphical interface created in Windows Forms App (.NET Framework), currently I already receive the information and I use a graph to show the behavior of these variables type floats but I need to store that information.
Thank you very much.
Thank you very much.
C#:
private void buttonSaveFile_Click(object sender, EventArgs e)
{
///crear un archivo
string path = "./TextData/TestFile.txt";
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
while (serialPort1.IsOpen && serialPort1.BytesToRead > 0)
{
string serialData = serialPort1.ReadLine();
try
{
for (int i = 0; i < 500; i++)
{
sw.WriteLine(serialPort1.ReadLine());
}
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
}
}
}
}
C#: