2015-01-11 4 views
-2
var file = await StorageFile.GetFileFromPathAsync(ImagePath); 

Здесь Путь изображения - это строка.Следующий код генерирует исключение при открытии файла

An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code

WinRT information: Cannot access the specified file or folder (폰ጼ¿). The item is not in a location that the application has access to (including application data folders, folders that are accessible via capabilities, and persisted items in the StorageApplicationPermissions lists). Verify that the file is not marked with system or hidden file attributes.

+0

Исключение кажется мне достаточно понятным - непонятно, каков ваш вопрос. Этот путь похож на тот, который существует на вашей машине? Если да, проверяете ли вы разрешения и атрибуты, как указано в исключении? –

+0

Путь существует в машине. Скажем, ImagePath - это C: \ Users \ superfast \ Desktop \ image.Jpg –

+0

Вы можете опубликовать значение 'ImagePath' при возникновении исключения? – dotctor

ответ

-1

Ошибка сообщает вам все, что вам нужно знать. От ошибки:

The item is not in a location that the application has access to (including application data folders, folders that are accessible via capabilities, and persisted items in the StorageApplicationPermissions lists)

Из вашего описания:

The path exists in the machine. Lets say the ImagePath is C:\Users\superfast\Desktop\image.Jpg

Ваше приложение не имеет доступа к этой папке. Вы можете узнать больше в статье MSDN на странице File access permissions

Смежные вопросы