简体   繁体   English

使用 UWP 和控制台中不同的目录/文件?

[英]Working with directories/files different in UWP and Console?

Simple question :-)简单的问题:-)

Can anyone explain me following: When I perform this code in console app (VS2015, C#, without the Async/Task.Run), it works and the directory is found.任何人都可以解释我以下内容:当我在控制台应用程序(VS2015,C#,没有 Async/Task.Run)中执行此代码时,它可以工作并找到目录。

However, when I run the same code with the same directory as variable in a Universal Windows Platform, the directory isn't found anymore.但是,当我使用与通用 Windows 平台中的变量相同的目录运行相同的代码时,不再找到该目录。 (So the script returns: is not a valid file or directory) (因此脚本返回:不是有效的文件或目录)

Here is the code:这是代码:

GetFilesList("E:\\Programmeren\\jpegs");

private async void GetFilesList(String path)
{
    await Task.Run(() =>
     {
         Task.Yield();
         if (File.Exists(path))
         {
            // This path is a file
            ProcessFile(path);
         }
         else if (Directory.Exists(path))
         {
            // This path is a directory
            ProcessDirectory(path);
         }
         else
         {
             Debug.WriteLine("{0} is not a valid file or directory.", path);
         }

     });
}

Any ideas?有任何想法吗?

In UWP, you only have access to your app's folder (installation folder, local folder and roaming folder of the app), public folder, video, photo and document folder and a limited number of other folders.在 UWP 中,您只能访问应用程序的文件夹(应用程序的安装文件夹、本地文件夹和漫游文件夹)、公共文件夹、视频、照片和文档文件夹以及有限数量的其他文件夹。

You can request access for the rest using FilePicker and FutureAccesList api.您可以使用FilePickerFutureAccesList api 请求访问其余部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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