How to start app by clicking file?

  • Thread starter Thread starter Brett Romero
  • Start date Start date
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
 
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.
 
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.
 
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
 
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.
 
Back
Top