当我尝试返回流时,通用 Windows 平台 10 TargetFile.OpenStreamForReadAsync() 给我一个错误“附加信息:访问被拒绝。(来自 HRESULT 的异常:0x80070005(E_ACCESSDENIED))”
public static async void StartReadFile(StorageFile TargetFile)
{
var stream = await TargetFile.OpenStreamForReadAsync();
ZipArchive z = new ZipArchive(stream);
var worksheet = z.GetEntry("xl/worksheets/sheet1.xml");
var sharedString = z.GetEntry("xl/sharedStrings.xml");
}
private async void PickUpFileButton_Click(object sender, RoutedEventArgs e)
{
string content = null;
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
openPicker.FileTypeFilter.Add(".xlsx");
StorageFile file = await openPicker.PickSingleFileAsync();
ExcelFileReader.StartReadFile(file);
if(file != null)
{
content = "file is saved";
}
else
{
content = "no file is saved";
}
}