Is there a trick to writing text to a file stored on MicroSD? I am trying to write text to it using a FileStream and StreamWriter, however even when I call Flush() on both the StreamWriter and FIleStream (in that order), data is very rarely written to the MicroSD card, to where files can be created and yet be 0 bytes long, even if I step through the code that writes and flushes data to that file in Visual Studio.
Furthermore, I am creating a file named "log.txt", and later in the program after I have retrieved the current date/time over Ntp, I call File.Move(). This results in no change to log.txt (still an empty file), or even worse: it simply deletes log.txt without creating the destination file. The netduino code manages to, despite this, still open and write to that file in code, yet never write any data to the MicroSD card.
I've confirmed that the microSD card works with a separate card reader, and I am able to write data to it just fine. The nature of the log (in that it is a debug log) means I can only call Close() on it if an exception is thrown as opposed to crashing in a non-exception state. Even if I am able to successfully call Flush() and then Close() on the StreamWriter and FileStream (Flush() on the StreamWriter first and then the FileStream, and then Close() on both) *and* call Thread.Sleep() to give the netduino time to write to the MicroSD card, no data is written and I'm unable to retrieve debug log information from the Netduino Plus 1.
Why does Flush() not immediately write data to the MicroSD card, nor apparently Close()?
Better yet, what could I be doing so catastrophically wrong that the netduino is apparently able to open and write to a file that, according to Windows afterwards, doesn't exist?