Hello there,

I am trying to create an application which will open once the associated file type is clicked. I have associated my application with the extension .agl, via Visual Studio. When I publish the application and install it, the file is associated properly with my application and when I double click an .agl file my application starts. However, the file that opened the application, is not passed as a command line argument and so I can't load it!

Does anyone have any idea why the opening file is not passed as a command line argument? Note that I am using Environment.GetCommandLineArgs() to get the arguments.

Thank you

The method returns only the first argument which is the path of the application.

>The method returns only the first argument which is the path of the application.

Of course the first argument will be a path and next will be a name of asso file. Please show us signature of Main() method.

>The method returns only the first argument which is the path of the application.

Of course the first argument will be a path and next will be a name of asso file. Please show us signature of Main() method.

What I am trying to say, is that the method returns only the path of the application and not the name of the associated file. The application is a WPF application and I can't find the Main() method.

>The application is a WPF application and I can't find the Main() method.

No problem!

string[] args = Environment.GetCommandLineArgs();
   string datafile=""
   if(args.Length==2)
        datafile=args[1];

>The application is a WPF application and I can't find the Main() method.

No problem!

string[] args = Environment.GetCommandLineArgs();
   string datafile=""
   if(args.Length==2)
        datafile=args[1];

This is what I am doing. The problem is that the returned string contains only the name of the application and not the path of the associated file opened. I think this has something to do with how I created the associations, and not with the code.

This article has been dead for over six months. Start a new discussion instead.