I have an issue when I try to write to in SD.
This is my code:
public static void SDWrite(string text, string filename, FileMode modo)
{
try
{
PersistentStorage sdPS = new PersistentStorage("SD");// Create a new storage device
sdPS.MountFileSystem();// Mount the file system
string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;// Access storage device
FileStream FileHandle = new FileStream(rootDirectory +
@ "\" + filename, modo);
byte[] data = Encoding.UTF8.GetBytes(text+"\r\n");
FileHandle.Write(data, 0, data.Length);
FileHandle.Flush();
FileHandle.Close();
sdPS.UnmountFileSystem();// Unmount file system
sdPS.Dispose();
}
catch (IOException ex) //???
{
dataLogger.addErrorLog(ex.Message, "errores.txt");
throw new SDIOException();
}
catch
{
throw new ApplicationException("Exception");
}
}
This is the error:
[quote]#### Exception System.IO.IOException - CLR_E_FILE_IO (4) ####
Message:
Microsoft.SPOT.IO.VolumeInfo::.ctor [IP: 0000]
Microsoft.SPOT.IO.RemovableMedia::MessageHandler [IP: 0022]
An unhandled exception of type ‘System.IO.IOException’ occurred in Microsoft.SPOT.IO.dll[/quote]
I’ve been looking for some info in Internet and I have found some interesting things:
http://netmf.codeplex.com/workitem/80
Any idea??