Hello,
I´m getting the folowing error when reading from a sd card (the 1st access is ok but all the others fail … coindcidence ?)
Does any boby can help me ?
Thanks
You are also constrained by memory. I don’t know how big the file is you are loading into the array but anything above 5k or so is going to cause other problems.
Bret, as far as I know the using ditective will detroy the filestream as soon as the program leaves the code between the ‘{ }’.Am I right ?
The ‘FilePath’ is a string that points to a file in the SD card; I have a class to read the SD card, and I found out a few minuts ago, if I declare the ‘PersistentStorage sd’ as static the problem does not happen any more. Here is the class code; I´m tring to undestand why !
class microSD
{
static PersistentStorage sd;
private static string _rootDirectory;
public static string rootDirectory
{
get { return _rootDirectory; }
set { _rootDirectory = value; }
}
public byte startSD()
{
try
{
sd = new PersistentStorage("SD");
sd.MountFileSystem();
if (VolumeInfo.GetVolumes()[0].IsFormatted)
{
rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
return 0;
}
else
return 1;
}
catch (Exception e)
{
return 2;
}
}
The use of the static makes the object or primitive “global” for the application and is single in existence. So if you initialize it, the reference is valid throughout the application.