1

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));
Binjal Shah
  • 311
  • 1
  • 9

1 Answers1

0

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.

csharpwinphonexaml
  • 3,659
  • 10
  • 32
  • 63