My Cerberus application mounts the SD card every 10 seconds, and writes text string into a file on the SD card and then dismounts it again. It keeps repeating this.
The mounting works fine for the first time, but then when it tries to write to the SD card for the first time it cause a failure like this : [quote]Failed allocation for 343 blocks, 4116 bytes[/quote]. But thereafter subsequent mounts->write->dismounts works just fine. However if I reboot the application it fails again for the first write.
The section of code where the SD card write happens that causes the failure is this:
DebugPrint(“Use Streamwriter to write a text file”);
StreamWriter textFile = new StreamWriter(_rootDirectory + filename, true);
textFile.WriteLine( “[” + DateTime.Now.ToString(“hh:mm:ss.fff”) + "] " + strdata);
This threw me for a while, because at first I only tried once and it made me think the writes to the SD card did not want to work at all. But then I tried to write repeatedly and found it was only the first write that fails.
I was interested to know if anyone else have experienced this behaviour. (I’m using VS2012 and NetMF 4.3)