0

I'm trying to build a simple application with C# and Windows forms in Visual Studio. I want to start by scanning available drives to see if any of them are phones or devices with a DCIM folder with images.

So far, I've found many guides on listing drives on the machine, but I'd like to iterate over them and select which are visible based on that. I'm ok with running PowerShell scripts to get the data if that's the best way - so long as it works in the end.

Additionally, I'm not clear which type of form element would be best to use to show the resulting data. If possible, I want to have the name/path of the found folder listed along with a small graphic showing the device type (somewhat like what the "This PC" view in Windows 10 does.

not_a_generic_user
  • 1,906
  • 2
  • 19
  • 34
  • Does this answer your question? [How to read files on Android phone from C# program on Windows 7?](https://stackoverflow.com/questions/25026799/) and [How to manage files on an MTP Portable Device?](https://stackoverflow.com/questions/18512737/) and [Get path of DCIM folder on both primary and secondary storage](https://stackoverflow.com/questions/29576098/) and [How to get the path to the internal memory of the smartphone and the DCIM folder?](https://stackoverflow.com/questions/44584067/) and [Check if directory exists in my connected phone C#](https://stackoverflow.com/questions/31905211/) –  Aug 10 '21 at 19:49

1 Answers1

1

You can get Drives by DriveInfo.GetDrives Method,
Then get Files by Directory.GetFiles Method

// Get drivers that have `DCIM` folder
List<string> drivesLetter = DriveInfo.GetDrives()
    .Where(d => Directory.Exists(Path.Combine(d.Name, "DCIM")))
    .Select(d => d.Name.Replace("\\", ""))
    .ToList();

// List files
foreach (string driver in drivesLetter)
{
    string dcimPath = Path.Combine(driver, "DCIM");
    // List files by dcimPath
}
CorrM
  • 498
  • 6
  • 18