Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch a file in UWP?

I want to launch the xml file from local state folder of my appx. I am unable to launch file using var file= ApplicationData.current.LocalFolder.GetFileAsync(); Launcher.LaunchFileAsync(file).Is there any way to launch the file in UWP?

like image 864
Vishnu s Avatar asked May 19 '17 06:05

Vishnu s


People also ask

How do I open a UWP file?

If you want to open a UWP app, you can go through the Start Menu, the apps list in the Start menu, you can create a desktop shortcut for them, or add them to the start up folder. If you want to open UWP apps from the command line on Windows, you can.

Is Microsoft killing UWP?

Microsoft continues to baby-step around the obvious, but it has officially deprecated the Universal Windows Platform (UWP) as it pushes the desktop-focused Windows App SDK (formerly called Project Reunion) and WinUI 3 as the future of Windows application development.

How do I open a file?

Press Ctrl+P. Now the default launch action for the file will be execute. If it is a mp3 or avi file it will be played by the default player for that file type, If it is a exe file it will start that program. It will do all this without you having to browse into the folder and launch the file yourself.


1 Answers

It seems that there is some issue with the default option you open the xml file with. And I have tried to launch a xml file with following code. And it works pretty well. The default application that I used to open xml file was Microsoft Edge.

string xmlFile = @"TextFile.xml";

var file = await ApplicationData.Current.LocalFolder.GetFileAsync(xmlFile);

if (file != null)
 {

     var success = await Launcher.LaunchFileAsync(file);

     if (success)
     {
         // File launched
     }
     else
     {
         // File launch failed
     }
 }
 else
 {
     // Could not find file
 }

Please try to change the default apps to load xml file normally.

like image 157
Nico Zhu - MSFT Avatar answered Sep 20 '22 03:09

Nico Zhu - MSFT