如何在Windows 8手机打开使用发射文档和图像 [英] How to open documents and images using launcher in windows phone 8

查看:237
本文介绍了如何在Windows 8手机打开使用发射文档和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的Windows Phone 8的应用程序,我不得不打开使用代码或文档发射器和图像。问题是,这些文档不开放那些没有在MS Office创建,我越来越像错误:

 文件有被损坏,无法打开和
文件格式不认可的

我的代码是在这里:

 字符串文件=TEST.XLS; 
VAR filerun =等待ApplicationData.Current.LocalFolder.CreateFileAsync(文件);

等待Launcher.LaunchFileAsync(的await ApplicationData.Current.LocalFolder.GetFileAsync(文件));


解决方案

试试这个代码



 字符串uriToLaunch = @http://www.contoso.com/SomeFile.docx 
变种的uri =新的URI(uriToLaunch);

异步无效DefaultLaunch()
{
//设置URI的内容类型
变种选项=新Windows.System.LauncherOptions();
options.ContentType =应用程序/ vnd.ms-word.document.12

//启动URI与内容类型
VAR成功=等待Windows.System.Launcher.LaunchUriAsync(URI,期权);

如果(成功)
{
// URI推出
}
,否则
{
// URI发射失败
}
}

搜索正确的MIME类型的文件


I am creating windows phone 8 app, I have to open docs and images using code or launcher. The problem is that those documents are not opening those are not created in MS Office, I am getting error like:

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

My code is here:

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

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

解决方案

Try this code

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
    }
}

Search for the right MIME type of your file.

这篇关于如何在Windows 8手机打开使用发射文档和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆