2015-07-10 117 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 
    } 
} 
相關問題