Home All Groups Group Topic Archive Search About

Command line argument

Author
28 Sep 2006 10:34 PM
snow
Hi all,

I want to drag a file and drop to my application icon on the desktop to
open the file. I use command line statement to catch the file location,
like the following:

dim cmd as string = Microsoft.VisualBasic.Command()

cmd is the file full path, it works if there is no white space in the
middle of the path. but if cmd contains a white space like cmd = "c:\my
documents\test.txt", it will show the error message "can't find the
file". I tried to use double quotes, it doesn't work either. Could
someone give me some suggestions?

Thanks in advance!

Author
29 Sep 2006 1:41 AM
Kerry Moorman
snow,

If you are using VB 2005 you might try using
My.Application.CommandLineArgs(0) instead of the Command function.

Kerry Moorman

Show quoteHide quote
"snow" wrote:

> Hi all,
>
> I want to drag a file and drop to my application icon on the desktop to
> open the file. I use command line statement to catch the file location,
> like the following:
>
> dim cmd as string = Microsoft.VisualBasic.Command()
>
> cmd is the file full path, it works if there is no white space in the
> middle of the path. but if cmd contains a white space like cmd = "c:\my
> documents\test.txt", it will show the error message "can't find the
> file". I tried to use double quotes, it doesn't work either. Could
> someone give me some suggestions?
>
> Thanks in advance!
>
>
Author
29 Sep 2006 4:55 PM
snow
I am using VB.NET 2003. The problem is when I am running the program in
debug mode, the variable cmd pass the file path, and function
File.exists(cmd) returns true; when running in release mode, function
File.exists(cmd) returns false, I wonder if it is the MS window issue.

thanks


Kerry Moorman wrote:
Show quoteHide quote
> snow,
>
> If you are using VB 2005 you might try using
> My.Application.CommandLineArgs(0) instead of the Command function.
>
> Kerry Moorman
>
> "snow" wrote:
>
> > Hi all,
> >
> > I want to drag a file and drop to my application icon on the desktop to
> > open the file. I use command line statement to catch the file location,
> > like the following:
> >
> > dim cmd as string = Microsoft.VisualBasic.Command()
> >
> > cmd is the file full path, it works if there is no white space in the
> > middle of the path. but if cmd contains a white space like cmd = "c:\my
> > documents\test.txt", it will show the error message "can't find the
> > file". I tried to use double quotes, it doesn't work either. Could
> > someone give me some suggestions?
> >
> > Thanks in advance!
> >
> >