我有一个使用.Net Framework 4.5.2的C#WinForm应用程序。我有一个拥有Windows 7虚拟机的环境。当我插入一个拇指驱动器时,Windows不会为其分配驱动器号,并且拇指驱动器将列在"其他"我的电脑上的类别。
我可以使用Windows资源管理器并单击并将文件拖到文件夹中,文件将被复制到拇指驱动器。这是我可以将文件复制到拇指驱动器的唯一方法。
问题是我无法使用.Net Framework来使用它。由于它没有驱动器号,因此我无法使用System.IO.File.Copy()。我还尝试在命令行中使用Volume Id和Windows copy。
System.IO.File.Copy( "a.pdf", System.IO.Path.Combine( @"\\?\Volume{c06fa891-c5a9-11e7-9bc6-f01faf0be092}\", "a.pdf" ) );
copy "a.pdf" "\\?\Volume{c06fa891-c5a9-11e7-9bc6-f01faf0be092}\a.pdf"
两者都给我相同的"参数不正确。"错误消息所以我猜测Windows资源管理器没有使用Volume ID来复制文件。
是否可以使用该方法使用.Net Framework复制Windows资源管理器使用的文件?
3/8更新 - 。我运行了Process Explorer,这是与拇指驱动器有关的一件事。做了一些搜索之后,我想这可能是WinAPI。
Event \Sessions\1\BaseNamedObjects\##?#STORAGE#Volume#_??_USBSTOR#Disk&Ven_VendorCo&Prod_ProductCode&Rev_2.00#92070841A6386815041&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
还运行了Process Monitor,日志显示资源管理器正在使用\ Client \ d $连接到拇指驱动器。
3:01:16.1677065 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance SUCCESS Query: Name
3:01:16.1677234 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance SUCCESS Query: HandleTags, HandleTags: 0x0
3:01:16.1677382 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance SUCCESS Query: HandleTags, HandleTags: 0x0
3:01:16.1677580 PM Explorer.EXE 2396 RegOpenKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Desired Access: Read
3:01:16.1678296 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: Name
3:01:16.1678500 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: HandleTags, HandleTags: 0x0
3:01:16.1678694 PM Explorer.EXE 2396 RegOpenKey HKCR\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag NAME NOT FOUND Desired Access: Maximum Allowed
3:01:16.1678906 PM Explorer.EXE 2396 RegQueryValue HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag\TargetSpecialFolder NAME NOT FOUND Length: 144
3:01:16.1679200 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: Name
3:01:16.1679382 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: HandleTags, HandleTags: 0x0
3:01:16.1679573 PM Explorer.EXE 2396 RegOpenKey HKCR\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag NAME NOT FOUND Desired Access: Maximum Allowed
3:01:16.1679755 PM Explorer.EXE 2396 RegQueryValue HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag\TargetKnownFolder NAME NOT FOUND Length: 144
3:01:16.1680023 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: Name
3:01:16.1680236 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: HandleTags, HandleTags: 0x0
3:01:16.1680427 PM Explorer.EXE 2396 RegOpenKey HKCR\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag NAME NOT FOUND Desired Access: Maximum Allowed
3:01:16.1680602 PM Explorer.EXE 2396 RegQueryValue HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag\Target SUCCESS Type: REG_SZ, Length: 24, Data: \\Client\D:
3:01:16.1680889 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: Name
3:01:16.1681067 PM Explorer.EXE 2396 RegQueryKey HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag SUCCESS Query: HandleTags, HandleTags: 0x0
3:01:16.1681249 PM Explorer.EXE 2396 RegOpenKey HKCR\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag NAME NOT FOUND Desired Access: Maximum Allowed
3:01:16.1681420 PM Explorer.EXE 2396 RegQueryValue HKCU\Software\Classes\CLSID\{8DA1D365-1E63-4531-B1DD-824E76DD6F72}\Instance\InitPropertyBag\Target SUCCESS Type: REG_SZ, Length: 24, Data: \\Client\D:
3:01:24.9065880 PM Explorer.EXE 2396 QueryDeviceInformationVolume \\Client\D$\a.pdf SUCCESS DeviceType: Disk, Characteristics: Remote, Removable
3:01:24.9066153 PM Explorer.EXE 2396 FileSystemControl \\Client\D$\a.pdf NOT IMPLEMENTED Control: IOCTL_LMR_DISABLE_LOCAL_BUFFERING
3:01:24.9066404 PM Explorer.EXE 2396 FileSystemControl \\Client\D$\a.pdf NOT IMPLEMENTED Control: FSCTL_LMR_QUERY_DEBUG_INFO
3:01:24.9068161 PM Explorer.EXE 2396 QueryBasicInformationFile \\Client\D$\a.pdf SUCCESS CreationTime: 0, LastAccessTime: 0, LastWriteTime: 3/8/2018 3:01:18 PM, ChangeTime: 3/8/2018 3:01:18 PM, FileAttributes: A
3:01:24.9068310 PM Explorer.EXE 2396 QueryStandardInformationFile \\Client\D$\a.pdf SUCCESS AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False
3:01:24.6940743 PM Explorer.EXE 2396 CreateFile \\Client\D$\a.pdf SUCCESS Desired Access: Generic Read/Write, Write DAC, Disposition: Create, Options: Sequential Access, Non-Directory File, Attributes: A, ShareMode: None, AllocationSize: 57,092,249, OpenResult: Created