-1

I am working on a WPF app, and I would like to include a button that directs it to another app. I would like it to have the following functionality:

  • If the app is installed on the user's computer, it opens the app for them.
  • If the app is not yet installed, it sends them to a link where they can download the app.

I know I will need to use Process.Start to open the app, but I am stuck on how to check if the app exists. If anyone could point me in the right direction it would be appreciated!

prelude38
  • 107
  • 7
  • `I am stuck on how to check if the app exists` its in your post already; check out https://www.google.com/search?q=how+to+check+if+the+app+exists+c%23. I don't see what the issue is here as you didn't provide any attempt at solving this solution. – Trevor Feb 10 '20 at 19:53

1 Answers1

0

Two things you can use:

  1. File.Exists(string) - Checks if the file exists.
  2. try-catch - Simply try to open it, and handle any exceptions.

I would probably opt for the first solution...

Jakob Busk Sørensen
  • 5,599
  • 7
  • 44
  • 96
  • and what if this application is a `UWP` application... just a thought? – Trevor Feb 10 '20 at 19:50
  • @Çöđěxěŕ since the tag states that the question is about WPF, I fail to see what UWP has to do with it? – Jakob Busk Sørensen Feb 10 '20 at 20:16
  • `How to get a WPF app to open another app if it exists` I would assume the OP is writing a `wpf` application and wants it to open another app if it exists... An application can be written in anything, if the application the OP wants to check for is done with UWP these solutions wont work. IMHO there's really no need to check for an application, just calling `Process.Start` [with arguments is sufficient](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=netframework-4.8#System_Diagnostics_Process_Start_System_String_) enough. – Trevor Feb 10 '20 at 20:20