我的项目中发生以下错误,有人能告诉我如何解决此异常吗?
访问被拒绝。 (Windows手机8.1中的HRESULT异常:0x80070005(E_ACCESSDENIED))。
我有这段代码:
using (IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read))
StorageFile file = usertoken ;
try
{
if (file != null)
{
using (IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read))
{
using (DataReader dataReader = new DataReader(readStream))
{
UInt64 size = readStream.Size;
UInt32 numBytesLoaded = await dataReader.LoadAsync((UInt32)size);
string fileContent = dataReader.ReadString(numBytesLoaded);
return (bool)true;
// NotifyUser(String.Format("The following text was read from '{0}' using a stream:{1}{2}", file.Name, Environment.NewLine, fileContent), NotifyType.StatusMessage);
}
}
}
else
{
return (bool)false;
}
}
catch
{
return (bool)false;
}
答案 0 :(得分:1)
您需要按照here的说明添加以下权限:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />