I am trying to read a file from the SD card and I got some real issues with it.
Code has been taken from an example on this site.
It only works about 20% of the time.
I have uploaded the firmware multiple times, as I thought it would reset the board and also deleted the app, but still no good.
Code used - put together, as split up into procedures of a class, shown below.
[quote]PersistentStorage m_oCard = new PersistentStorage( “SD” );
m_oCard.MountFileSystem( );
RemovableMedia.Insert += RemovableMedia_Insert;
RemovableMedia.Eject += RemovableMedia_Eject;
…
public void RemovableMedia_Insert( object sender, MediaEventArgs e )
{
VolumeInfo oVolume = VolumeInfo.GetVolumes()[0];
XmlReaderSettings oReader = new XmlReaderSettings( );
oReader.IgnoreWhitespace = true;
oReader.IgnoreComments = true;
FileStream oConfigFile = new FileStream( oVolume.RootDirectory + @ “\test.conf”, FileMode.OpenOrCreate, FileAccess.Read );
XmlReader xmlr = XmlReader.Create( oConfigFile, oReader );
while ( !xmlr.EOF )
{
xmlr.Read( );
…
}
…
}[/quote]
I get exceptions at the following lines:
- new PersistentStorage( “SD” );
- FileStream oConfigFile = new FileStream( oVolume.RootDirectory + @ “\test.conf”, FileMode.OpenOrCreate, FileAccess.Read );
- XmlReader xmlr = XmlReader.Create( oConfigFile, oReader );
- xmlr.Read( );
When looking at the exception object, it just says “Exception”, no code or message.
Have to reboot computer again, so will add another post with output messages.
Would be great if anyone has got an idea.
development env:
windows server 2003R2 in virtual machine (Parallels) on macBook pro.
VS 2010 ultimate