如何在windows phone 8中使用启动器打开文档和图像

本文关键字:启动 文档 图像 windows phone | 更新日期: 2023-09-27 18:15:40

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

如何在windows phone 8中使用启动器打开文档和图像

试试这个代码

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