get name of file opened through file association

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2009
Posts: 4
Reputation: Kloukip is an unknown quantity at this point 
Solved Threads: 0
Kloukip Kloukip is offline Offline
Newbie Poster

get name of file opened through file association

 
0
  #1
Oct 14th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 324
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 39
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz
 
0
  #2
Oct 14th, 2009
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.

  1. Public Static Void Main(string[] Args)
  2. {
  3.  
  4. //you can use it here by using Args[0] to refference it or you can pass it to the first form like:
  5.  
  6. Application.Run(new Form1(Args));
  7.  
  8. }

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

  1. string[] appArgs;
  2. public Form1( string[] Args)
  3. {
  4. appArgs = Args;
  5. }

happy coding!
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 4
Reputation: Kloukip is an unknown quantity at this point 
Solved Threads: 0
Kloukip Kloukip is offline Offline
Newbie Poster
 
0
  #3
Oct 15th, 2009
Thank you, very helpful!
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 1
Reputation: d3hartm1 is an unknown quantity at this point 
Solved Threads: 0
d3hartm1 d3hartm1 is offline Offline
Newbie Poster
 
0
  #4
24 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 324
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 39
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz
 
0
  #5
23 Days Ago
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.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC