I tried the v4.2 firmware briefly. Had big problems working with SD card (256MB) on the Plus. Seemed like it would only work with files in the root directory.
Trying to access anything in a sub-directory (eg, GetFiles) would throw a NotSupported exception. Same code working fine in the 4.1 beta so rolled back to that for now.
// try this code, it should work for reading subdirectories.
// call read ReadDirectories() and it will spin through all diriectories and sub-directories on the card.
// The file reader assumes you are reading test files out to debug console.
public void ReadFiles( String sDirectory ) {
String sLine = String.Empty;
string[] files = System.IO.Directory.GetFiles(sDirectory);
Debug.Print("file count: " + files.Length.ToString());
for (int i = 0; i < files.Length; i++) {
Debug.Print("filename: " + files[i]);
FileStream fs = new FileStream(files[i], FileMode.Open, FileAccess.Read, FileShare.None, 512);
StreamReader sr = new StreamReader(fs);
Debug.Print("contents: " );
do {
sLine = sr.ReadLine();
Debug.Print(sLine);
} while( sLine == String.Empty );
sr.Close();
fs.Close();
}
}
public void ReadSubDirectories( String sDirectory ) {
try {
ReadFiles( sDirectory );
string[] directories = System.IO.Directory.GetDirectories(sDirectory);
Debug.Print("directory count: " + directories.Length.ToString());
for (int i = 0; i < directories.Length; i++) {
Debug.Print("directory: " + directories[i]);
ReadSubDirectories( directories[i] );
}
}
catch {}
}
public void ReadDirectories() {
string[] directories = System.IO.Directory.GetDirectories(@"\");
Debug.Print("directory count: " + directories.Length.ToString());
for (int i = 0; i < directories.Length; i++) {
Debug.Print("directory: " + directories[i]);
ReadSubDirectories( directories[i] );
}
}