[英]Access is denied. Exception from HRESULT: 0x80070005 in Windows Phone 8.1
I am developing Windows Phone 8.1 Silverlight app, 我正在开发Windows Phone 8.1 Silverlight应用程序,
I am trying to Upload document from my SD card but getting this error. 我正在尝试从我的SD卡上传文档,但收到此错误。
Access is denied. Exception from HRESULT: 0x80070005
System.UnauthorizedAccessException
I have also added Capability "ID_CAP_REMOVABLE_STORAGE" in WMAppManifest file. 我还在WMAppManifest文件中添加了功能“ID_CAP_REMOVABLE_STORAGE”。 But didn't work.
但没有奏效。
See my code below: 请参阅下面的代码:
private async void UploadDocument()
{
StorageFolder externalDevices = KnownFolders.RemovableDevices;
StorageFolder sdCard = (await externalDevices.GetFoldersAsync()).FirstOrDefault();
if (sdCard != null)
{
//An SD card is present and the sdCard variable now contains a reference to it
}
else
{
// No SD card is present.
}
}
WP8.1 has also new manifest file - Package.appxmanifest - ensure that you have also added capability there - Location . WP8.1还有新的清单文件 - Package.appxmanifest - 确保你还在那里添加了功能 - 位置 。 Also you will have to add file type association as it's Silverlight .
此外,您还必须添加文件类型关联,因为它是Silverlight 。
Though (I don't know why) you will have to add this the first time from code - right click on Package.appxmanifest file -> View code and add for example like this in application/Extensions section: 虽然(我不知道为什么)你必须在代码中第一次添加它 - 右键单击Package.appxmanifest文件 - > 查看代码并在application / Extensions部分添加例如:
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="text">
<DisplayName>Text file</DisplayName>
<SupportedFileTypes>
<FileType ContentType="text/file">.txt</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
Once you add it and save, you be able to add/edit FileTypeAssociations via graphic UI. 添加并保存后,您可以通过图形用户界面添加/编辑FileTypeAssociations 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.