[UWP] BroadFileSystemAccess与可移动设备 [英] [UWP]BroadFileSystemAccess with removable devices

查看:261
本文介绍了[UWP] BroadFileSystemAccess与可移动设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我将我的UWP应用配置为使用broadFileSystemAccess。它适用于文档库和其他所有文件库,但在可移动设备方面我无能为力。我无法枚举哪些可移动设备可用。我还想以递归方式列出可移动设备中的所有文件夹
和文件。

I configured my UWP app to use broadFileSystemAccess. It works with the documents library and all the rest, but i can't do anything when it comes to removable devices. I can't enumerate which removable devices are available. I also want to list all folder and files in a removable device recursively.

有人可以帮我解释为什么broadFileSystemAcess不能让我访问可移动设备吗?

Can someone please help me with why broadFileSystemAcess can't let me access removable devices?

推荐答案

>>我不能枚举哪些可移动设备可用。

>>I can't enumerate which removable devices are available.

好吧,您似乎想要获得所有可移动设备。 BroadFileSystemAccess功能可以让您通过路径访问可移动设备中的文件夹,但这并不意味着您可以直接获取可移动设备。 

Well, it seems that you wants to get all the removable devices. BroadFileSystemAccess capability could let you access the folder in the removable devices with path but it does not means you could get the removable devices directly. 

如果您需要获取所有文件夹和所有可移动设备中的文件,您可以尝试使用 KnownFolders.RemovableDevices属性。 

If you need to get all the folders and files from all the removable devices, you could try to use KnownFolders.RemovableDevices Property. 

例如,我有一个可移动存储设备。它显示为:I:\\在我的电脑中。当我需要访问I盘时,我将使用如下代码:

For example, I have a removable storage device. It shows like : I:\\ in my computer. When I need to access the I disk, I will use code like this:

 StorageFolder Removefolder = KnownFolders.RemovableDevices;
            var folders = await Removefolder.GetFoldersAsync();

            foreach (StorageFolder folder in folders)
            {
                if (folder.Name.Equals("I:\\"))
                {
                   
                   StorageFile file1 = await folder.GetFileAsync("debug.txt");
                    Debug.WriteLine(file1.Path);

                }
            }

注意:您需要为访问设置两个关键事项 可移动文件夹。首先,您需要指定
可移动存储功能。其次,在app清单中,至少注册一个文件类型关联声明。此声明明确指出应用程序要在可移动设备上访问的文件类型(扩展名)。
应用程序只能枚举,创建或更改具有在应用程序清单中声明的​​文件类型的文件

Note: there are two key things that you need to set for accessing the removable folder. First you need to specify the Removable Storage capability. Second, in the app manifest, register at least one File Type Association declaration. This declaration explicitly indicates the file types (extensions) that your app wants to access on the removable devices. The app can only enumerate, create, or change files that have the file types declared in the app manifest

致以最好的问候,

Roy


这篇关于[UWP] BroadFileSystemAccess与可移动设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆