1

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));
4

1 に答える 1

0

このコードを試してください

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 タイプを検索します。

于 2014-07-31T12:56:40.913 に答える