7heViking
7heViking

Reputation: 7577

Open file on start up

I don't know what it is called but I want to be able to double click on my saved file and then my program should open and load the file. What is this called and how do I do it?

I am using c# wpf and .net 4.0

BR

How about the last 2 fields, what am I supposed to write there?

enter image description here

Upvotes: 2

Views: 1339

Answers (2)

Davide Piras
Davide Piras

Reputation: 44605

you need to register the file extension and associate it to your program, either during the setup using certain APIs or from code when program executes the first time.

check these ones:

How to associate a file extension to the current executable in C#

Associate File Extension with Application

personally I do not like the 100% registry approach, there should be some Windows APIs for that and we should let those APIs to work without worrying about the Registry from our side, in my opinion.

Upvotes: 1

brunnerh
brunnerh

Reputation: 184376

That is a file association, if you want this to happen on a client machine you need to register your application as the default application for a given extension. This question might be handy.

To actually handle the opening you need to process the arguments that are handed to your application, they will contain the file path. You can get the arguments either in the override of Application.OnStartup (e.Args) or Environment.GetCommandLineArgs.

Upvotes: 6

Related Questions