2

My WPF app has .xyz files that can open it (used the WIX installer), however, in my WPF app, I'd like to somehow capture this and call some loading functionality of the file that was double-clicked on from the File Explorer before the application was started.

Right now, if you double click the appropriate xyz file from File Explorer, it opens the application but obviously nothing else happens. Is there a way in my WPF code to detect this and call the necessary function passing in the filepath/name?

2 Answers 2

2

You should be able to the file path in your App.xaml.cs class:

public partial class App : Application { public static string FilePath { get; private set; } protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); if (e.Args != null && e.Args.Length > 0) FilePath = e.Args[0]; } } 

If you store in a static property like this, you could access it from any class in your app:

string filePath = App.FilePath; 
Sign up to request clarification or add additional context in comments.

1 Comment

thanks mm8. Don't understand why i keep getting downvoted :(...
2

In Application there is the StartUp event where you can set your arguments. Follow this example

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.