Link to home
Start Free TrialLog in
Avatar of Guy2
Guy2Flag for France

asked on

long filename argument in dotNet application

I am writing a dotNet application.  This application accepts argument in the Main function.  I want to be able to drag and drop a file onto this application.  When the file has a normal filename (ie without space), everything works fine.  When the file has a long filename with space, then I want the filename to be considered as one argument surrounded with double quotes (ie not 2 arguments when there is a space in the filename).

This dotNet application may have switches.

One example is when I create a *.bat file.  When I drag and drop another file onto this *.bat file, the %1 argument contains a filename surrounded by double quotes.

How can I achieve this in dotNet?
Avatar of karstieman
karstieman
Flag of Netherlands image

I'm not quite sure why there has to be a problem with long filenames, but you can declare a string and put the filename into. That way you can have as mush spaces as you'd like.
Avatar of Guy2

ASKER

As the application allow switches, some spaces are normal whereas some are within the long filename.  I want to distinguish between the two.  Moreover, in a drag and drop scenario, I do not know in advance the filename that will be used.
Avatar of Mike Tomlinson
What version VB.net?...and is there a STRONG reason for starting with Sub Main()?
Avatar of Guy2

ASKER

VB.Net 2.0.

I understand that Sub Main is the only way we can get command line arguments.  Is there any other way?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Guy2

ASKER

Good!