a place for robotic enthusiasts, builders and user groups
Debug.Print( "[TEST] : {MicroSDTest} Starting..." );
Debug.Print( "[TEST] : {MicroSDTest} Detecting SD Card" );
if ( PersistentStorage.DetectSDCard() )
{
Debug.Print( "[TEST] : {MicroSDTest} SD Card Detected!" );
Debug.Print( "[TEST] : {MicroSDTest} Mounting Persistent Storage device" );
PersistentStorage storage = new PersistentStorage( "SD" );
storage.MountFileSystem();
Debug.Print( "[TEST] : {MicroSDTest} Fetching volumes" );
VolumeInfo [] volumeInfoArray = VolumeInfo.GetVolumes();
if ( volumeInfoArray != null && volumeInfoArray.Length > 0 )
{
Debug.Print( "[TEST] : {MicroSDTest} Volume Retrieved" );
VolumeInfo primaryVolume = volumeInfoArray [0];
Debug.Print( "[TEST] : {MicroSDTest} Determining if Volume is formatted" );
if ( primaryVolume.IsFormatted )
{
Debug.Print( "[TEST] : {MicroSDTest} Volume is formatted" );
Debug.Print( "[TEST] : {MicroSDTest} Device Flags : "
+ primaryVolume.DeviceFlags.ToString() );
Debug.Print( "[TEST] : {MicroSDTest} File System : "
+ primaryVolume.FileSystem );
Debug.Print( "[TEST] : {MicroSDTest} File System Flags : "
+ primaryVolume.FileSystemFlags.ToString() );
Debug.Print( "[TEST] : {MicroSDTest} Name : " + primaryVolume.Name );
Debug.Print( "[TEST] : {MicroSDTest} Root Directory : "
+ primaryVolume.RootDirectory );
Debug.Print( "[TEST] : {MicroSDTest} Serial Number : "
+ primaryVolume.SerialNumber.ToString() );
Debug.Print( "[TEST] : {MicroSDTest} Total Free Space : "
+ primaryVolume.TotalFreeSpace.ToString() );
Debug.Print( "[TEST] : {MicroSDTest} Total Size : "
+ primaryVolume.TotalSize.ToString() );
Debug.Print( "[TEST] : {MicroSDTest} Volume ID : "
+ primaryVolume.VolumeID.ToString() );
Debug.Print( "[TEST] : {MicroSDTest} Volume Label : "
+ primaryVolume.VolumeLabel );
Debug.Print( "[TEST] : {MicroSDTest} Checking SD card for the test file" );
if ( File.Exists( primaryVolume.RootDirectory + "\\test.txt" ) )
{
Debug.Print( "[TEST] : {MicroSDTest} test.txt was found - deleting!" );
File.Delete( primaryVolume.RootDirectory + "\\test.txt" );
}
Debug.Print( "[TEST] : {MicroSDTest} Creating test.txt file" );
FileStream stream = File.Create( primaryVolume.RootDirectory + "\\test.txt" );
StreamWriter writer = new StreamWriter( stream );
writer.WriteLine( "hello sd card!" );
writer.Flush();
writer.Close();
writer.Dispose();
Debug.Print( "[TEST] : {MicroSDTest} Checking SD card for files" );
string [] filenameArray = Directory.GetFiles( primaryVolume.RootDirectory );
if ( filenameArray != null && filenameArray.Length > 0 )
{
Debug.Print( "[TEST] : {MicroSDTest} Files were found!" );
}
}
else
{
Debug.Print( "[TEST] : {MicroSDTest} Volume is not formatted" );
}
}
Debug.Print( "[TEST] : {MicroSDTest} Unmounting Persistent Storage" );
storage.UnmountFileSystem();
Debug.Print( "[TEST] : {MicroSDTest} Disposing of Persistent Storage" );
storage.Dispose();
}
Debug.Print( "[TEST] : {MicroSDTest} Completed!" );
Peter Farkas posted a video
Peter Farkas posted a blog post© 2012 Created by Danny.
| Add Videos | Add Photos | Post a Blog | Add Events | Discuss | Form a Group | ||
Sign Up Invite |