我的应用程序中有一些 pdf 文件(项目文件),我想如何在 Adobe Reader 或其他软件中打开,但我不知道如何。
在 iOS 中更容易,在 Android 中我知道如何,但我不知道在 WP8 中如何。
我是 Windows Phone 8 的新手:/
谢谢大家!
我的应用程序中有一些 pdf 文件(项目文件),我想如何在 Adobe Reader 或其他软件中打开,但我不知道如何。
在 iOS 中更容易,在 Android 中我知道如何,但我不知道在 WP8 中如何。
我是 Windows Phone 8 的新手:/
谢谢大家!
你必须使用类的LaunchFileAsync
方法Launcher
。例子:
// Access the file.
StorageFile pdfFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("file.pdf");
// Launch the pdf file.
Windows.System.Launcher.LaunchFileAsync(pdfFile);
您将在此处找到更多信息:
将下载的文件保存到隔离存储...
async void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
byte[] buffer = new byte[e.Result.Length];
await e.Result.ReadAsync(buffer, 0, buffer.Length);
using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = storageFile.OpenFile("your-file.pdf", FileMode.Create))
{
await stream.WriteAsync(buffer, 0, buffer.Length);
}
}
}
打开并显示隔离存储中的 pdf 文件。
// Access the file.
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile pdffile = await local.GetFileAsync("your-file.pdf");
// Launch the pdf file.
Windows.System.Launcher.LaunchFileAsync(pdffile);
async void launchPDF()
{
string fileURL = @"Assets\file.pdf";
StorageFile pdfFile = await
Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileURL);
if (pdfFile != null)
{
IAsyncOperation<bool> success =
Windows.System.Launcher.LaunchFileAsync(pdfFile);
if (await success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
}
}
确保 pdf 文件构建操作是内容