Two SD Card Questions

Curious mind so I ask.

UCM Dev Board Rev E with a UC5550 Rev c and UD700 Rev A
Libs version 1.0.0-preview2
VS 2017 Version 15.8.5
Windows 10 Pro

My App was made for no particular reason other than see if I could get the SD Card on the Dev Board working.

I was getting nowhere really fast and then I found:
FileStream.Read Method (System.IO) | Microsoft Learn

I finally had something I could understand (Sort of).

I can now create directories and write/read simple text files.

It appears that the SD card does not need any special initializing. (Happy Face)

I have two question about things I tried that I could not get to work.

  1. Changing
    I used

    private static StorageController sc;
    private static IDriveProvider drive;
    private static FileStream file

    // UC5550 is a STM32F7
    sc = StorageController.FromName(@“GHIElectronics.TinyCLR.NativeApis.STM32F7.SdCardStorageController\0”);
    drive = FileSystem.Mount(sc.Hdc);

    // The following changes the name to B:\ but it causes Exception if used
    drive.Name = $@“B:";
    file = new FileStream($@”{drive.Name}\SDTestNoFolder.txt", FileMode.Create);
    (An unhandled exception of type ‘System.NullReferenceException’ occurred in GHIElectronics.TinyCLR.IO.dll)

  2. How to
    public static bool Unmount(IntPtr hdc);

    How and when to use it.

Thank You

Drive.Name shouldn’t be changed, the setter will probably be made private/internal.

Unmount follows the same pattern as mount and is used when you’re done with the SD card:

var sd = StorageController.FromName("");
var drive = FileSystem.Mount(sd.Hdc);




That is what I used but I can’t find my notes on what exception I received.

Thank You for the reply