2015-07-10 218 views
1

请告诉我如何使用c#从Windows商店应用程序启动桌面应用程序或.exe文件。如何从Windows Store应用程序启动桌面应用程序?

任何帮助将非常感激。提前致谢!

+0

'Process.Start'如何? – Herdo

+0

这不是不可能的。和问题看起来像重复http://stackoverflow.com/questions/17969019/is-there-a-possibility-to-start-another-app-or-program-from-a-windows-8-store-ap – feeeper

+0

@Herdo此命名空间在Windows应用商店应用中不可用 –

回答

2

如注释中所述,由于沙盒环境,您无法直接从Windows应用商店应用启动可执行文件。但是,您可以使用launcher API来启动与文件关联的可执行文件。因此,您可以在自定义文件扩展名和要启动的应用程序之间创建文件关联。然后,只需使用启动程序API打开具有自定义文件扩展名的文件即可。

public async void DefaultLaunch() 
{ 
    // Path to the file in the app package to launch 
    string imageFile = @"images\test.png"; 

    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile); 

    if (file != null) 
    { 
     // Launch the retrieved file 
     var success = await Windows.System.Launcher.LaunchFileAsync(file); 

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