VB problem with spaces in filenames

VB problem with spaces in filenames

Post by dg » Thu, 10 Jan 2002 05:00:13



In VB6 I want to pass a path to the Inet control, but when
there are spaces in the filename, the file isn't recognized.

Inet.Execute "ftp://myhost.com", "PUT " & "LocalPath" & " " & TargetPath

If LocalPath = C:\test.txt it works file but if LocalPath = C:\My Documents\
Administrator\My Documents\test.txt FTP chokes on it.

I'm new to VB. Is there a workaround for this?

Thanks
Dimitri

 
 
 

VB problem with spaces in filenames

Post by Sin » Thu, 10 Jan 2002 05:20:51


Try adding " before and after the string...

Something like:

Inet.Execute "ftp://myhost.com", "PUT """ & "LocalPath" & """ " & TargetPath

(not sure about "" being the right way... been a long time since I've done
any VB... you can also try \" ? )

Alex.

Quote:> In VB6 I want to pass a path to the Inet control, but when
> there are spaces in the filename, the file isn't recognized.

> Inet.Execute "ftp://myhost.com", "PUT " & "LocalPath" & " " & TargetPath

> If LocalPath = C:\test.txt it works file but if LocalPath = C:\My
Documents\
> Administrator\My Documents\test.txt FTP chokes on it.

> I'm new to VB. Is there a workaround for this?


 
 
 

1. BUG: GetOpenFileName() removes leading spaces in filename

GetOpenFileName() will display in its file list any files that have
leading spaces.  But if you select one, and press Open,
GetOpenFileName() will delete off the leading spaces from
the filename returned to your program.

This happens on Win98 and WinNT4.0 but not Win2000.

Does anyone know how to get around this bug?  I consider
it a bug since the file is properly listed in the dialog but
the incorrect name is returned.

You can reproduce this by creating a file with leading spaces
in a command windows by the command

echo hello > "     hello.txt"

Then try to open the file with the File->Open menu option
in notepad.  You will get an error message stating that
"hello.txt" (without the leading spaces) does not exist.

Any help or suggestions are appreciated.

Jim Boyle

2. winblows

3. Debugging VB add-ins?

4. Tk port needs your help

5. Long Filenames from 8.3 Filenames

6. What is vb.exe?

7. How do I expand a short filename to a long filename?

8. Short Filenames to Long Filenames

9. HOWTO: Matching Filename to Filename Pattern?

10. Long filename to short filename

11. Short Filenames to Long Filenames

12. Long FileName - Short Filename conversion