C# Windows Phone 8.1中的文档打开问题

C# Windows Phone 8.1中的文档打开问题,c#,windows-phone-8.1,document,C#,Windows Phone 8.1,Document,我正在创建Windows Phone 8.1应用程序,我正在尝试使用launcher打开文档,但出现异常,文档不是MS OFFICE文档,而是在其他软件中创建的。这是我的密码 string file = "readme.txt"; IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); if (isf.FileExists(file)) { isf.DeleteFile(file); } v

我正在创建Windows Phone 8.1应用程序,我正在尝试使用launcher打开文档,但出现异常,文档不是MS OFFICE文档,而是在其他软件中创建的。这是我的密码

string file = "readme.txt";
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();

if (isf.FileExists(file))
{
   isf.DeleteFile(file);
}

var filerun = await ApplicationData.Current.LocalFolder.CreateFileAsync(file);
await Launcher.LaunchFileAsync(await ApplicationData.Current.LocalFolder.GetFileAsync(file));
我得到的错误如下:

"Can't be Open, File Format doesn't recognize"
"Document has been damaged"
有时是这样的:

"Can't be Open, File Format doesn't recognize"
"Document has been damaged"

我不知道如何处理这个问题,我被困在这里,任何帮助都将不胜感激。

没有扩展名的文件名是“campaign rev 2”,因此传递给启动器的文件肯定不是“readme.txt”

您可以将
LaunchOptions.DisplayApplicationPicker
传递给
LaunchFileAsync
方法

var filerun = await ApplicationData.Current.LocalFolder.CreateFileAsync(file);
var options = new Windows.System.LauncherOptions(){ DisplayApplicationPicker = true};
await Launcher.LaunchFileAsync(filerun, options);
它将打开一个应用程序列表供您选择,因此您可以检查文件扩展名实际上是.txt或.xls/.xlsx(Excel)

根据,此重载在Windows Phone 8.1上可用。但是我还没有升级到8.1,所以我不能给你一个应用程序选择器的屏幕截图

网络截图。希望这有帮助


错误发生在哪一行代码中?什么是异常类型?@kennyzx错误在代码之间没有发生,当我点击文档打开后,出现一个消息框,给我这样的消息:“无法打开”。非常感谢。请建议me@kennyzx查看我的编辑和屏幕截图。谢谢兄弟
它是在其他软件中创建的
,其他软件如何写入应用程序的本地文件夹?从您的代码中,我看到这个文件是由应用程序创建的:
var filerun=wait ApplicationData.Current.LocalFolder.CreateFileAsync(文件)
@kennyzx,是的,我的意思是它是在“开放式办公软件”中创建的,我想打开这个文档,我对这个问题不太了解,所以对此我很抱歉。但如何解决呢?请告诉我!!我的意思是“readme.txt”或“campaign rev 2.xls”都没有打开。我给出了像“readme.txt”这样的例子。谢谢。kennyzx,我使用了你的上一个代码,但仍然得到一个错误。请看我的另一个屏幕截图。非常感谢。