我想写一个应用程序,这将复制MP3文件迪珊M240.闪迪没有一个驱动的信,并使用中期计划文件的传送。我偶然发现了通过样品连接的设备: http://blogs.msdn.com/dimeby8/archive/2006/09/27/774259.aspx

但是,一旦相连的,我想不出如何实际上复制文件的创建文件夹上的设备。

我非常惊讶的是,没有任何.净的包装这COM图书馆。

有帮助吗?

解决方案

看起来像dimeby8发布了一些处理数据传输的代码。查看他博客中的其他帖子,特别是:

通过WPD第1部分发送MTP命令

通过WPD第2部分发送MTP命令

通过WPD第3部分发送MTP命令

其他提示

传送文件的通过中期计划c#:

  1. 下载这NuGet: PortableDevices

  2. 添加提到这4COM库:

    • PortableDeviceClassExtension
    • PortableDeviceConnectApi
    • PortableDeviceTypes
    • PortableDeviceApi
  3. 采取dll下 obj\Debug 并把它们放进 bin\Debug:

    • Interop.PortableDeviceClassExtension.dll
    • Interop.PortableDeviceConnectApiLib.dll
    • Interop.PortableDeviceTypesLib.dll
    • Interop.PortableDeviceApiLib.dll

现在你可以用下面的功能清单的所有设备,尽管 FriendlyName 似乎没有工作(就返回的一个空string):

    private IDictionary<string, string> GetDeviceIds()
    {
        var deviceIds = new Dictionary<string, string>();
        var devices = new PortableDeviceCollection();
        devices.Refresh();
        foreach (var device in devices)
        {
            device.Connect();
            deviceIds.Add(device.FriendlyName, device.DeviceId);
            Console.WriteLine(@"DeviceId: {0}, FriendlyName: {1}", device.DeviceId, device.FriendlyName);
            device.Disconnect();
        }
        return deviceIds;
    }

下一步是获取内容的设备,这样做是像这样:

var contents = device.GetContents();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top