连接可移动驱动器HidSharp Linux时如何创建事件

时间:2018-12-17 08:38:08

标签: c# .net linux mono usb-drive

我尝试使用nuget包HidSharp 2.0.5在连接/断开可移动驱动器时捕获事件。我现在正在Windows上进行调试,但是我的代码是未捕获任何隐藏的设备连接事件。我将来会通过Mono在Linux上运行此应用程序。谁能帮我吗? 简单代码:

static void Main(string[] args)
    {
        var list = DeviceList.Local;

        Console.WriteLine("USB monitor");

        list.Changed += (sender, e) => Console.WriteLine("Device list changed.");

        var hidDeviceList = list.GetHidDevices().ToArray();

        Console.WriteLine("Complete device list {0} devices:", hidDeviceList.Length);

        foreach (var device in hidDeviceList)
        {
            Console.WriteLine(device);
        }

        Console.ReadLine();
    }

enter image description here

0 个答案:

没有答案