我正在创建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"
我不知道如何处理这件事,我被困在这里,任何帮助都将不胜感激。
发布于 2014-09-17 20:44:38
不带扩展名的文件名是"campaign rev 2",因此传递给启动器的文件肯定不是"readme.txt“。
您可以向LaunchFileAsync
方法传递一个LauncherOptions.DisplayApplicationPicker
。
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)。
根据documentation的说法,Windows phone8.1上存在此重载。但是我还没有升级到8.1,所以我不能给你一个应用程序选择器的截图。
来自网络的截图。希望这能有所帮助。
https://stackoverflow.com/questions/25884654
复制相似问题