我试图用下面的代码启动pdf阅读器,但它不起作用。有人能帮助我吗?在Windows Phone 8上启动PDF阅读器8
private async Task<StorageFile> WriteData(string fileName, byte[] data)
{
StorageFolder folder = ApplicationData.Current.LocalFolder;
StorageFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
using (Stream s = await file.OpenStreamForWriteAsync())
{
await s.WriteAsync(data, 0, data.Length);
s.Close();
}
return file;
}
private async Task<bool> OpenPdf(StorageFile file)
{
var uri = new Uri(file.Path, UriKind.RelativeOrAbsolute);
bool result = await Windows.System.Launcher.LaunchUriAsync(uri);
return result;
}
private async void FetchPdf() {
// Fetch pdf bytes to network
//....
StorageFile file = await WriteData("test.pdf", data);
if (file != null) {
bool result = await OpenPdf(file);
if (result)
Debug.WriteLine("Success");
else
Debug.WriteLine("Cannot open pdf file.");
}
}
结果总是错误的,所以发射器不会显示。
我使用了LaunchUriAsync,因为LaunchFileAsync未在Windows Phone上实现。
由文档在Visual Studio误导,你可以在这里看到:https://imagizer.imageshack.us/v2/881x175q90/401/pozq.png – rdon
我可以测试这个模拟器上? – user2056563
@ user2056563我不确定你在问什么。 – WiredPrairie