Search code examples
c#androidfilecopyingmtp

C# - Copying files from an Android Device to desktop


So I want to make a program in C# that allows users to import/export files between an Android's device and a PC. Could someone point me in the right direction because I'm lost, I've read some suggestions on the internet that MTP might have something to do with it.

Windows Explorer shows the directory of the phone as: Computer\GT-I9300T\Phone\Android\data.

I made a batch file that outputs the current directory, put that in the Android folder on my device and ran it off my computer. The output was: C:\TEMP\WPDNSE{01700131-0175-0142-8301-9101B3019D01}. I went into that folder in Windows Explorer and the only thing within that folder was the CD.bat that I made, with no other files or folders.

I don't know if it will make much difference, but my phone is a Samsung Galaxy S3 GT-I9300T on firmware 4.3.

Any help would be greatly appreciated.


Solution

  • When you connect this device to your computer, it's not mounted as a normal filesystem (like a hard drive or USB stick). Rather, the OS accesses the device's filesystem via MTP.

    As far as I know there is no managed API for accessing MTP, but you can still interact with them from C# via COM. You will need to use the Portable Device APIs. It's quite complicated though. Check this blog post to get you started.