[英]Document opening issue in Windows Phone 8.1
我正在創建Windows Phone 8.1應用程序,試圖使用啟動器打開文檔,但是出現異常,並且該文檔不是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"
我不知道如何處理,我被困在這里,任何幫助將不勝感激。
沒有擴展名的文件名為“ campaign rev 2”,因此傳遞給啟動器的文件絕對不是“ readme.txt”。
您可以將LauncherOptions.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,因此無法為您提供應用程序選擇器的屏幕截圖。
網絡截圖。 希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.