Home All Groups Group Topic Archive Search About

Filename from Open With

Author
14 Aug 2006 2:44 PM
smay
I'm building a small app that is launched by right-clicking on an XML file
and choosing "Open With...".  Ugly, I know, but I can't associate .xml with
my app.  Anyway, once the app is launched, how can I get the full path to the
XML file that was opened?

Author
14 Aug 2006 3:42 PM
Jim Wooley
I believe using Open With passes as a parameter to the opening application
the full path and filename of the document to be opened. Once you grab the
file parameter as a switch from My.Application.CommandLineArgs. Once you
have the string, use System.IO.Path.GetFullPath to retrieve only the path
portion.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

Show quoteHide quote
> I'm building a small app that is launched by right-clicking on an XML
> file and choosing "Open With...".  Ugly, I know, but I can't associate
> .xml with my app.  Anyway, once the app is launched, how can I get the
> full path to the XML file that was opened?
>
Author
14 Aug 2006 4:02 PM
smay
You are right.  The full path and file name are passed as the first and only
arg.  Thanks very much!

Show quoteHide quote
"Jim Wooley" wrote:

> I believe using Open With passes as a parameter to the opening application
> the full path and filename of the document to be opened. Once you grab the
> file parameter as a switch from My.Application.CommandLineArgs. Once you
> have the string, use System.IO.Path.GetFullPath to retrieve only the path
> portion.
>
> Jim Wooley
> http://devauthority.com/blogs/jwooley/default.aspx
>
> > I'm building a small app that is launched by right-clicking on an XML
> > file and choosing "Open With...".  Ugly, I know, but I can't associate
> > .xml with my app.  Anyway, once the app is launched, how can I get the
> > full path to the XML file that was opened?
> >
>
>
>
Author
14 Aug 2006 3:57 PM
Cyril Gupta
Hello smay,

What Open with... does is... Pass the file name you have clicked as a commandline
argument to your application. So what you should be looking for is how to
read the commandline arguments from your application.

I think in .Net + VB, this can be done pretty easily.

System.Environment.GetCommandLineArgs()

I think that should do the trick... but I am writing from memory, and I could
be wrong. Let me know if you get anywhere

Regards
Cyril Gupta

You can do anything with a little bit of 'magination.

Show quoteHide quote
> I'm building a small app that is launched by right-clicking on an XML
> file and choosing "Open With...".  Ugly, I know, but I can't associate
> .xml with my app.  Anyway, once the app is launched, how can I get the
> full path to the XML file that was opened?
>