Hello,

What to do so that when a user double click on a file which extension is
recognised by my application, my application starts and opens this file?

I made an installer that create the expected file association, but when i
double click on a file whith the correct extension, my application is
launched but he file not opend.

Someone can help?

Pascal

RE: open from dskop by jason_whitted[at]hotmail[dot]com>

jason_whitted[at]hotmail[dot]com>
Wed Nov 10 10:52:02 CST 2004

When you double click an "associated" file, it passes the path of the
associated file to the associated program as an argument. You have to handle
this argument in your application.

An example would look like:

using System;
using System.IO;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
{
public Form1(string[] args)
{
if(args.Length>0 && File.Exists(args[0]))
{
MessageBox.Show(String.Format("TODO: Implement code to open the
'{0}' file.", args[0]);
}
}

public static void Main(string[] args)
{
Application.Run(new Form1(args));
}
}

In the VS.NET IDE, you can "pass" command line arguments to the application
by doing the following:

Open up the Project's Properties Dialog Box. In the "Configuration
Properties" section, select "Debugging". In the "Start Options" section,
specify the desired file's path in the "Command Line Arguments" section.

Hope that helps.

--
Jason Whitted

Re: open from dskop by Pascal

Pascal
Wed Nov 10 13:29:06 CST 2004

Hello Jason,

Thank you very much for your advices.

I have just try it and it works fine (after analyzing the args, because .net
creates a new arg each time it encounter a space caracter ).

It remains just one question in my mind. In the installer project, i created
a file association and i have associated an action to my file type; this
action has a property called "Verb" to which i have afected the value "open"
as it is suggested in the documentation. What is the role of this property
and how to use this property in my application?

thanks again in advance

Pascal




"JWhitted" <jason_whitted[at]hotmail[dot]com> a écrit dans le message de
news: 0A50932E-382D-49A8-9DEE-5803E3D23B9F@microsoft.com...
> When you double click an "associated" file, it passes the path of the
> associated file to the associated program as an argument. You have to
> handle
> this argument in your application.
>
> An example would look like:
>
> using System;
> using System.IO;
> using System.Windows.Forms;
>
> public class Form1 : System.Windows.Forms.Form
> {
> public Form1(string[] args)
> {
> if(args.Length>0 && File.Exists(args[0]))
> {
> MessageBox.Show(String.Format("TODO: Implement code to open
> the
> '{0}' file.", args[0]);
> }
> }
>
> public static void Main(string[] args)
> {
> Application.Run(new Form1(args));
> }
> }
>
> In the VS.NET IDE, you can "pass" command line arguments to the
> application
> by doing the following:
>
> Open up the Project's Properties Dialog Box. In the "Configuration
> Properties" section, select "Debugging". In the "Start Options" section,
> specify the desired file's path in the "Command Line Arguments" section.
>
> Hope that helps.
>
> --
> Jason Whitted