以下代码在打开文件时抛出异常
The following Code throws exception while opening the file
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.
该错误告诉您您需要知道的一切。来自错误:
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
您的应用无权访问该文件夹。您可以在 File access permissions
上的 MSDN 文章中找到更多信息
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.
该错误告诉您您需要知道的一切。来自错误:
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
您的应用无权访问该文件夹。您可以在 File access permissions
上的 MSDN 文章中找到更多信息