File association - Problem with argument begin passed in

  • Thread starter Thread starter Justin F
  • Start date Start date
J

Justin F

I have set up file association for my application (VB.Net). I'm having
problems getting the filename that was double-clicked. On my machine at
work, if the filename being passed in to the application has spaces in any
of the folder names, they get split up at every space. This happens
regardless if I use a Sub Main(ByVal args() as String) or use
System.Environment.GetCommandLineArgs(). For example, if I launch a file
that's on my desktop, the string array is something like this (I am not able
to open the file unless I were to append args together to make a complete
path\filename, which doesn't seem too safe to me):
args(0) = C:\Documents
args(1) = and
args(2) = Settings\MyUsername\Desktop\MyFile.sql

If I run the same application on my computer at home, args looks like this
(I am able to open the file):
args(0) = C:\Docume~1\MyUser~1\Desktop\MyFile.sql

My question is twofold. Why does this act differently on two machines both
running WinXP Pro SP2? And what is the "right" way to get the complete
path\filename?

Thanks,
Justin
 
In the file association, enclose the argument in quotation marks. For
example, in the registry, the setup for a .vbproj file is as follows:

"C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
"%1"


Notice that the %1 is inside quotation marks.

In the registry under your file association, look at the open registry key
and make sure the %1 is in quotation marks. That should keep it from being
split on the spaces.

HTH
 
Chris Dunaway said:
In the file association, enclose the argument in quotation marks. For
example, in the registry, the setup for a .vbproj file is as follows:

"C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
"%1"


Notice that the %1 is inside quotation marks.

In the registry under your file association, look at the open registry key
and make sure the %1 is in quotation marks. That should keep it from being
split on the spaces.

HTH

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

That worked, thanks a bunch!
 
Back
Top