using System;
using System.IO;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.FEZ;
namespace FEZ_Domino_SD_Application2
{
public class Program
{
public static void Main()
{
// ...
// SD Card is inserted
// Create a new storage device
PersistentStorage sdPS = new PersistentStorage("SD");
// Mount the file system
sdPS.MountFileSystem();
// Assume one storage device is available, access it through
// Micro Framework and display available files and folders:
Debug.Print("Getting files and folders:");
if (VolumeInfo.GetVolumes()[0].IsFormatted)
{
string rootDirectory =
VolumeInfo.GetVolumes()[0].RootDirectory;
string[] files = Directory.GetFiles(rootDirectory);
string[] folders = Directory.GetDirectories(rootDirectory);
Debug.Print("Files available on " + rootDirectory + ":");
for (int i = 0; i < files.Length; i++)
Debug.Print(files[i]);
Debug.Print("Folders available on " + rootDirectory + ":");
for (int i = 0; i < folders.Length; i++)
Debug.Print(folders[i]);
}
else
{
Debug.Print("Storage is not formatted. Format on PC with FAT32/FAT16 first.");
}
// Unmount
sdPS.UnmountFileSystem();
}
}
}
using System;
using System.Threading;
using System.Text;
using Microsoft.SPOT;
using System.IO;
using Microsoft.SPOT.IO;
using GHIElectronics.NETMF.IO;
namespace FEZ_Domino_SD_Application3
{
public class Program
{
public static void Main()
{
// ... check if SD is inserted
// SD Card is inserted
// Create a new storage device
PersistentStorage sdPS = new PersistentStorage("SD");
// Mount the file system
sdPS.MountFileSystem();
// Assume one storage device is available,
// access it through NETMF
string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
FileStream FileHandle = new FileStream(rootDirectory + @ "\hello.txt", FileMode.Create);
byte[] data =
Encoding.UTF8.GetBytes("This string will go in the file!");
// write the data and close the file
FileHandle.Write(data, 0, data.Length);
FileHandle.Close();
// if we need to unmount
sdPS.UnmountFileSystem();
// ...
Thread.Sleep(Timeout.Infinite);
}
}
}
@ Gus,
If you enlarge the pic under my first two posts then you find Microsoft.SPOT.IO in the reference tables.
So thas is not the reason.
By the way I havenot got that folder that you mention, not in “all user” either.
I followed the standard information while installing VS2010Express and VS2010Prof.
@ Architect,
Reflector? I searched for that. Is it an extra debugger on top of the VS2010 one?
Or do you need Refelctor because you use antocher development system then VS2010.
And yes system.io.dll is at the right place. Ducumentation must be wrong.
You have to add System.IO.dll to your references. I don’t see it in the pics you have posted.
Reflector is a .net “disassembler” - very handy tool that allows you to look inside compiled assemblies. If code is not obfuscated it will try it best to turn IL back into C#/VB.NET and other managed languages that it supports.
This is one of the must have tools for any .Net developer.
I echo the observation and complaint - I had a dickens of a time tonite (wasted over an hour of very precious time) chasing down a really basic item that needs to be clearly documented and isn’t.
Just some basic engineering principles - if you’re going to share code, then tell everyone about the #includes! (using’s in c#) and mention what References to load/add for the example code to work.
The problem is that there are several differences between .NET MF and original recipe .NET that unless someone documents things carefully in these examples, you spend needless hours chasing articles of undocumented minutia.
@ Wim: You can also view using VS 2010 Prof. by clicking on the Class View tab under the Solution Explorer window on the right side of the screen. If You open references, click on Class View; VS 2010 has reflector built-in.
while it would be nice to have the necessary references included as comments within a program, it is easy to find the necessary information in the sdk documentation.