예제 #1
0
        public static USBDeviceInfo GetInitializedUsb(IEnumerable <USBDeviceInfo> devices)
        {
            var device = devices.SingleOrDefault(d =>
            {
                var sync = new USBSync(d);
                return(sync.Match());
            });

            return(device);
        }
예제 #2
0
        private void VolumeClick(object sender, EventArgs e)
        {
            var btn   = sender as Button;
            var t     = btn.Text;
            var start = t.LastIndexOf("(") + 1;
            // 从像 xxx(x:) 的字符串中提取盘符
            var dir = t.Substring(start, t.Length - start - 1);

            var usbSync = new USBSync(dir);

            if (usbSync.Match())
            {
                MessageBox.Show("此 U 盘已被正确初始化,可以正常使用");
            }
            else
            {
                usbSync.InitUsb();
                this.Controls.Remove(btn);
                this.main.Show();
                MessageBox.Show("初始化成功");
                this.Close();
            }
        }