Cerbuino Bee: SD-Card - how to access in 4.3

Hi,
I could not find out yet how to access the SD-Card of Cerbuino Bee in 4.3.
In 4.2 I used:

GHI.OSHW.Hardware.StorageDev.MountSD();

The same question will arise for the SD-Card of Cobra II.

Thanks in advance.
Roland

This example works fine on the Cerbuino within the context of this example.
But the same code inserted in a Gadgeteer-app resulted in a exception error…I am looking into this issue …will be continued…

@ andre.m -
in a Gadgeteer App the code throws an exception (see picture)

@ freeck Your posts change the content very fast
:open_mouth:
Which assembly should be used?

Seems to work without creating an SDCard instance. Seems to be already done behind the Scenes.


using System.IO;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.IO;
using GHI.IO;
using GHI.IO.Storage;
using Gadgeteer.Modules.GHIElectronics;

namespace Cerbuino_SD_Test
{
    public partial class Program
    {
        void ProgramStarted()
        {
            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!");
            }
        }
    }
}

O.K. But then… how to unmount without knowing the Name?

Perhaps this is sufficient


private void FinalizeVolumes()
        {
            VolumeInfo[] vi = VolumeInfo.GetVolumes();
            for (int i = 0; i < vi.Length; i++)
                vi[i].FlushAll();
        }

@ RoSchmi - In 4.3, mainboards with onboard functionality have it taken care of inside the mainboard driver. So for the Cerbuino Bee, USB Host and SD Card are all managed and initialized for you. Just look on the Mainboard object for the definitions.

@ John - thanks John
so the SD-Card is automatically mounted after boot and after plugging in another SD-Card that I don’t have to use the Mainboard.MountStorageDevice() method and can use the VolumeInfo object at once.
Before plugging out, I have to use
Mainboard.UnmountStorageDevice().
Right?

Can this already be found somewhere in the documentation?
Cheers
Roland

@ RoSchmi - That is correct, though I would wait for the mounted events to be raised before using VolumeInfo. We do not have a document covering this at this time, but you can read the documentation on the public members of Mainboard and take a look at the source on our BitBucket.

@ John - thanks!