从PC以编程方式访问Android设备上的文件 [英] Programmatically access files on android device from PC

查看:206
本文介绍了从PC以编程方式访问Android设备上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序,将需要访问我的android平板电脑上的文件,显然我可以仅使用已安装的驱动器号进行存储,但是我将在多个位置部署此驱动器号,并且需要一种一致的方式来访问文件.我可以通过编程方式调用ADB,但同样,我将其部署在多个位置,并且无法在每个系统上安装SDK.

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.

所以我想我正在寻找: 1)使用C#(或Java)以编程方式访问设备 或2)使用ADB,而不必在每个位置都安装SDK 或3)以编程方式找出所连接设备的驱动器号

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. HTC Sync是一个以这种方式工作的应用程序示例,如果有人知道该应用程序是如何做到的,那将是完美的.

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.

推荐答案

这就是我想出的东西,也许您可​​以从这里开始.

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;

这篇关于从PC以编程方式访问Android设备上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆