我試圖用下面的代碼啓動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