469,924 Members | 1,397 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

File association - Problem with argument begin passed in

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
Nov 22 '05 #1
6 1950
Sorry, the WinXP machines have SP1, not SP2...my mistake.
"Justin F" <x@x.us> wrote in message news:LbRec.3008$bl.126@okepread03...
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

Nov 22 '05 #2
Sorry, the WinXP machines have SP1, not SP2...my mistake.
"Justin F" <x@x.us> wrote in message news:LbRec.3008$bl.126@okepread03...
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

Nov 22 '05 #3
On Tue, 13 Apr 2004 08:27:02 -0500, Justin F wrote:
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


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.
Nov 22 '05 #4
On Tue, 13 Apr 2004 08:27:02 -0500, Justin F wrote:
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


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.
Nov 22 '05 #5
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1i*****************************@40tude.net...
On Tue, 13 Apr 2004 08:27:02 -0500, Justin F wrote:
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

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!
Nov 22 '05 #6
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1i*****************************@40tude.net...
On Tue, 13 Apr 2004 08:27:02 -0500, Justin F wrote:
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

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!
Nov 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by A_StClaire_ | last post: by
165 posts views Thread by Dieter | last post: by
2 posts views Thread by techspirit | last post: by
28 posts views Thread by Tim Daneliuk | last post: by
185 posts views Thread by jacob navia | last post: by
16 posts views Thread by John Doe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.