Reputation: 127
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.
However, when I run the same code with the same directory as variable in a Universal Windows Platform, the directory isn't found anymore. (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?
Upvotes: 1
Views: 89
Reputation: 1942
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.
You can request access for the rest using FilePicker
and FutureAccesList
api.
Upvotes: 1