简体   繁体   中英

How to check if the chosen path comes from USB or network drive?

在UWP(和WinRT)中是否可以检查通过打开对话框选择的文件/文件夹是否来自可移动磁盘或网络位置?

Get Drive Type will tell you if it's a network drive or not. Unfortunately the API listed in that page for detecting USB isn't available to UWP.

The only way I found was to call Win32 API directly:

    [DllImport("api-ms-win-core-file-l1-1-0.dll")]
    private static extern DriveType GetDriveType([MarshalAs(UnmanagedType.LPStr)] string lpRootPathName);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM