I am attempting to get a list of all files in a directory on the SD card.
Is this possible with current implementations? I was not able to find any function to do so.
Thanks
I am attempting to get a list of all files in a directory on the SD card.
Is this possible with current implementations? I was not able to find any function to do so.
Thanks
System.IO.Directory.GetFiles(string folderpath)
This isn’t working? I am just starting to work with the SDCard and programmed it up this way but haven’t given it a try yet.
Yeah, just tried this on a usb drive and it works as expected.
using System.Diagnostics;
using System.IO;
using System.Threading;
using GHIElectronics.TinyCLR.Devices.Storage;
using GHIElectronics.TinyCLR.IO;
namespace SD_Test
{
class Program
{
static void Main()
{
var sd = StorageController.FromName(@"GHIElectronics.TinyCLR.NativeApis.STM32H7.SdCardStorageController\0");
var drive = FileSystem.Mount(sd.Hdc);
// Show a list of files on root directory
var directory = new DirectoryInfo(drive.Name);
var files = directory.GetFiles();
foreach (var f in files)
{
Debug.WriteLine(f.Name);
}
FileSystem.Flush(sd.Hdc);
Thread.Sleep(Timeout.Infinite);
}
}
}
Thanks guys, I couldn’t find the DirectoryInfo class. Will give this a go tomorrow.
We are starting the samples repo this week. You are all invited to contribute and suggest please
I would really like an integrated sample project with a Main program from where you can instantiate FileSystem, CAN, networking etc. from separate classes and a threading sample e.g. for FileSystem.