I am attempting to code a text log file that is stored on the PandaII SD card. the issue that I have is that I only get one line of text regardless of how many write attempts I make. What is my issue? Also I would like to write the new lines at the end of the file. All guidance appreciated!!!
Thanks,
K
public bool UpdateSD(string fileName, string dataToFile)
{
SDCard = new PersistentStorage("SD");
SDCard.MountFileSystem();
if (VolumeInfo.GetVolumes()[0].IsFormatted)
try
{
string root = VolumeInfo.GetVolumes()[0].RootDirectory;
string fileToWrite = root + @ "\" + fileName;
FileStream dataWriter = new FileStream(fileToWrite, FileMode.OpenOrCreate, FileAccess.Write);
byte[] data = Encoding.UTF8.GetBytes(dataToFile);
dataWriter.Write(data, 0, data.Length);
dataWriter.Close();
}
catch
{
Debug.Print("Write to SD failed");
return false;
}
Thread.Sleep(2);
SDCard.Dispose();
return true;
}