Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

rmatteson

Member Since 25 Jan 2012
Offline Last Active Jan 28 2012 03:43 AM
-----

Posts I've Made

In Topic: Netduino Firmware v4.2.0 BETA 1

27 January 2012 - 09:57 PM

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] );
}
}

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.