944,070 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1236
  • C# RSS
Oct 14th, 2009
0

get name of file opened through file association

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kloukip is offline Offline
4 posts
since Mar 2009
Oct 14th, 2009
0
Re: get name of file opened through file association
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.

C# Syntax (Toggle Plain Text)
  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

C# Syntax (Toggle Plain Text)
  1. string[] appArgs;
  2. public Form1( string[] Args)
  3. {
  4. appArgs = Args;
  5. }

happy coding!
Reputation Points: 442
Solved Threads: 89
Master Poster
Diamonddrake is offline Offline
721 posts
since Mar 2008
Oct 15th, 2009
0
Re: get name of file opened through file association
Thank you, very helpful!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kloukip is offline Offline
4 posts
since Mar 2009
Nov 4th, 2009
0
Re: get name of file opened through file association
Quote ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
d3hartm1 is offline Offline
3 posts
since Nov 2009
Nov 5th, 2009
0
Re: get name of file opened through file association
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.
Reputation Points: 442
Solved Threads: 89
Master Poster
Diamonddrake is offline Offline
721 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: How to play Video?
Next Thread in C# Forum Timeline: Algorithm LR parse for c sharp





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC