1

我正在创建 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));
4

1 回答 1

0

试试这个代码

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 类型。

于 2014-07-31T12:56:40.913 回答