Search code examples
c#xmlwpffile-association

Open file with application


I have .xml file to store my data from my application.

Now I would like to click on the .xml file -> start my application with data loaded from the .xml file.

What makes application to run the xml parsing metods ?

I have no idea how to do this, what exactly happens when I open .xml file with my application ? Does Windows fetch the application some kind of parameter with .xml file path or something ? Also WPF does not seem to have the Main() method which usually handles these parameters.

Any idea how to do it ?


Solution

  • So here is what I did:

    I made my own file extension .xxx (inside there is just plain xml) when I open it with my application I check in constructor of startup window for the parameters count using the

    Environment.GetCommandLineArgs()

    If count > 1 I get the second parameter which is string with absolute path to the file. Then I fetch the string to the method handling the opening of the file.