Hi!
I was wondering how to access the name (location,...) of a file I doubleclick on and that opens in my application through the Windows extension association.
Thanks
-Klo

Its a little ambiguous. do you want to know how to set file associations? or know how to catch the arguments passed to your app after its been associated?

I will assume the 2nd one, as the nature of the question looks to be of that.

you must modify your Main() function. If you are using microsoft visual studio on a Forms application this will be inside the "program.cs" file in the project solution. you must modify the Main method to accept a string array.

Public Static Void Main(string[] Args)
{

//you can use it here by using Args[0] to refference it or you can pass it to the first form like:

Application.Run(new Form1(Args));

}

of course if you send it to Form1 this way you must alter form1's constructor to accept it

string[] appArgs;
public  Form1( string[] Args)
{
     appArgs = Args;
}

happy coding!

Thank you, very helpful! ;)

Its a little ambiguous. do you want to know how to set file associations? or know how to catch the arguments passed to your app after its been associated?

Can you explain how to set file associations in Visual C#? I know it's in the Publish -> Options -> File Association dialog, but I don't see how to set the association so that it will pull in the file name/path (%1 / %L). Thanks.

Its not a good practice to ask a new question on an expired thread. but setting windows explorer file association is done 2 ways, both in the registry. there are great articles in code project about it. go have a look.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.