1

I have a OnePlus attached to a Windows machine via USB.

I can see the file system objects on it via File Explorer.

Phone drives in File Explorer

The phone is exposed via two locations, the D: drive, which is mounted as a CDFS and contains some OnePlus drivers.

The other, labeled ONEPLUS A6013 which contains the OS file system.

How do I access the volume labeled ONEPLUS A6013 from .NET?

There's no drive for it returned by the DriveInfo.GetDrives() and I can't reference it by the path in File Explorer?

This PC\ONEPLUS A6013\Internal shared storage\Documents
BanksySan
  • 27,362
  • 33
  • 117
  • 216

1 Answers1

0

I've found a solution here https://stackoverflow.com/a/60478271/4412472

A MediaDevices nuget package is required.

The code may look like this:

static void EnumerateOnePlusFiles()
{
    var deviceName = "ONEPLUS A5010";

    var devices = MediaDevice.GetDevices();
    var device = devices.First(d => d.FriendlyName == deviceName);

    device.Connect();

    var photoDir = device.GetDirectoryInfo(@"\Internal shared storage\DCIM\Camera");
    var files = photoDir.EnumerateFiles("*.*", SearchOption.AllDirectories);

    foreach (var file in files)
    {
        Console.WriteLine(file.FullName);
    }

    device.Disconnect();
    device.Dispose();
}
Ivan
  • 355
  • 2
  • 14