【问题标题】:How to open documents and images using launcher in windows phone 8如何在 windows phone 8 中使用启动器打开文档和图像
【发布时间】:2014-07-31 06:31:20
【问题描述】:

我正在创建 windows phone 8 应用程序,我必须使用代码或启动器打开文档和图像。问题是那些文档没有打开那些不是在 MS Office 中创建的,我收到如下错误:

"Document has been damaged, cant open" and
"File Format doesn't recognized"

我的代码在这里:

string file = "Test.xls";
var filerun = await ApplicationData.Current.LocalFolder.CreateFileAsync(file);

await Launcher.LaunchFileAsync(await ApplicationData.Current.LocalFolder.GetFileAsync(file));

【问题讨论】:

  • 文档是否在应用外打开(直接在 Office 应用中)?
  • @pwas 不,无法在任何地方打开,我不知道如何打开,文档是在“打开 Office”软件中创建的。谢谢大佬!!请指导我
  • @csharpwinphonexaml 你能用代码告诉我吗,我真的不知道。谢谢

标签: c# windows-phone-8 app-launcher


【解决方案1】:

试试这个代码

string uriToLaunch = @"http://www.contoso.com/SomeFile.docx";
var uri = new Uri(uriToLaunch);

async void DefaultLaunch()
{
    // Set the URI’s content type
    var options = new Windows.System.LauncherOptions();
    options.ContentType = "application/vnd.ms-word.document.12";

    // Launch the URI with the content type
    var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

    if (success)
    {
        // URI launched
    }
    else
    {
        // URI launch failed
    }
}

搜索文件的正确 MIME 类型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多