Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

c# - Programmatically access files on android device from PC

I have a C# application that will need to access files that are on my android tablet, obviously I can just use the mounted drive letter for the storage but I will be deploying this at multiple locations and need a consistent way to access the files. I'm able to call ADB programmatically, but again, I am deploying it at multiple locations and can't install the SDK on every system.

So I guess I'm looking to either: 1) programmaticaly access the device using C# (or java) or 2) Use ADB without having to install the SDK at each location or 3) Find out the drive letter of the attached device programmatically

As you could have guessed I'm trying to make this as seamless as possible

P.S. An example of an application that works this way is HTC Sync, If anyone knows how that application does it that would be perfect.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's what I came up with for you to maybe start with.

var drives = DriveInfo.GetDrives();

var removableFatDrives = drives.Where(
        c=>c.DriveType == DriveType.Removable &&
        c.DriveFormat == "FAT" && 
        c.IsReady);

var andriods = from c in removableFatDrives
               from d in c.RootDirectory.EnumerateDirectories()
               where d.Name.Contains("android")
               select c;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...