5

我的应用程序中有一些 pdf 文件(项目文件),我想如何在 Adob​​e Reader 或其他软件中打开,但我不知道如何。

在 iOS 中更容易,在 Android 中我知道如何,但我不知道在 WP8 中如何。

我是 Windows Phone 8 的新手:/

谢谢大家!

4

3 回答 3

6

你必须使用类的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);

您将在此处找到更多信息:

使用 Windows Phone 8 的文件和 URI 关联自动启动应用程序

于 2013-07-12T13:26:03.227 回答
2

将下载的文件保存到隔离存储...

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);
于 2014-03-06T11:43:46.307 回答
0
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 文件构建操作是内容

于 2013-07-26T23:54:57.440 回答