How to start app by clicking file?

B

Brett Romero

I'd like to start my app by double clicking a file. Via the file
extension, it should know the app to load. The file will contain
several IDs in XML, which my gets data off of and loads into a datagrid
relevant to these IDs. Here is what I'm not sure on.

1.) How does the OS or what ever is monitoring know which app to load
from the file extension?

2.) Once my app loads, how do I create an entry point to start
processing the file data?

3.) If I have three applications, three file extensions and want the
user to have a choice of which app to load (b/c certain apps can handle
multiple extensions), how is that done? I guess it would be using
steps 1 and 2 to load a little app that allows selection of the other
apps.

What is this particular topic called? I wasn't sure what to search
under.

Thanks,
Brett
 
S

Steph.

You have to register the extension of your file and the application to open it.



In the Windows Explorer : click the Menu Tools/Options and Select the "FileType" Tab.


Steph.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Brett Romero said:
I'd like to start my app by double clicking a file. Via the file
extension, it should know the app to load. The file will contain
several IDs in XML, which my gets data off of and loads into a datagrid
relevant to these IDs. Here is what I'm not sure on.

1.) How does the OS or what ever is monitoring know which app to load
from the file extension?

It's stored in the registry, the file is passed as a parameter. You will
have to register that extension to your program.
 
B

Brett Romero

Here's part 2:

[STAThread]
static void Main(string[] args)
{
if (args.Length > 0)
{
//open files and read contents
foreach (string filename in args)
{
//file processing
}
}
else
{
loadUser_Init();
frmMaster MainForm = new frmMaster();
System.Windows.Forms.Application.Run(MainForm);
}
}

This will also take care of #3. Another app will need to be created
that catches all relevant file executions. It gives the user options
of which app to open.

Brett
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

So this will solve your problem?

Not sure of the if though, the idea is that you process the file in the
same way you would do by selecting File/Open from the menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top