none
How to open Microsoft Office Docs from my Windows 8 metro style application(C#)

    Question

  • Hi,

    I have a windows 8 metro style application .That application fetches files from web service.there are doc files , ppt, excel .I want to open those files from my application .How to do that?

    Monday, July 02, 2012 12:10 PM

Answers

  • generally you can use Windows.System.Launcher.LaunchUriAsync(Uri) or Windows.System.Launcher.LaunchFileAsync(IStorageFile)


    Tuesday, July 03, 2012 7:59 AM
  • you will get something like this:

    public

    asyncvoidDownloadAndOpenFile()

            {

               

    varfile = awaitKnownFolders.DocumentsLibrary.CreateFileAsync("filename.docx");

               

    HttpClientclient = newHttpClient();

               

    vardocumentStream = awaitclient.GetStreamAsync("urltodocument");

               

    vartargetStream = awaitfile.OpenAsync(FileAccessMode.ReadWrite);

               

    awaitdocumentStream.CopyToAsync(targetStream.AsStreamForWrite());

               

    awaitLauncher.LaunchFileAsync(file, newLauncherOptions{ DisplayApplicationPicker = true});

            }

    dont forget the manifest file to add document library

    Tuesday, July 03, 2012 2:35 PM

All replies

  • save file to document librarie and use the launcher

    Monday, July 02, 2012 1:45 PM
  • Thanks Dave for your reply .Can you please send me a code snippet for this .And which launcher I need to use?
    Tuesday, July 03, 2012 5:24 AM
  • generally you can use Windows.System.Launcher.LaunchUriAsync(Uri) or Windows.System.Launcher.LaunchFileAsync(IStorageFile)


    Tuesday, July 03, 2012 7:59 AM
  • you will get something like this:

    public

    asyncvoidDownloadAndOpenFile()

            {

               

    varfile = awaitKnownFolders.DocumentsLibrary.CreateFileAsync("filename.docx");

               

    HttpClientclient = newHttpClient();

               

    vardocumentStream = awaitclient.GetStreamAsync("urltodocument");

               

    vartargetStream = awaitfile.OpenAsync(FileAccessMode.ReadWrite);

               

    awaitdocumentStream.CopyToAsync(targetStream.AsStreamForWrite());

               

    awaitLauncher.LaunchFileAsync(file, newLauncherOptions{ DisplayApplicationPicker = true});

            }

    dont forget the manifest file to add document library

    Tuesday, July 03, 2012 2:35 PM