How to handle space in directory name with FtpSetCurrentDirectory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to FTP a file to an FTP server -- the destination path has spaces.

When I interactively change directory using FTP in a command window, I can
put double quotes around a directory name that has one or more spaces. Then
the CD command will work.

However, in my C program, I cannot figure out how to handle the space(s) in
the directory name for use with FtpSetCurrentDirectory.

Including double quotes within the directory string doesn't help:
sprintf(szDir, "\"%s\"", szPathWithSpaces);

Please Help!
 
Bryce said:
I need to FTP a file to an FTP server -- the destination path has spaces.

When I interactively change directory using FTP in a command window, I can
put double quotes around a directory name that has one or more spaces. Then
the CD command will work.

However, in my C program, I cannot figure out how to handle the space(s) in
the directory name for use with FtpSetCurrentDirectory.

Including double quotes within the directory string doesn't help:
sprintf(szDir, "\"%s\"", szPathWithSpaces);

Please Help!

Have you tried not quoting it?

ie: maybe FtpSetCurrentDirectory will manage the problem of the space
characters for you.
 
doug mansell said:
Have you tried not quoting it?

ie: maybe FtpSetCurrentDirectory will manage the problem of the space
characters for you.

Sorry but it doesn't. That's how I discovered the problem. I've tried
replacing the spaces with everything I could think of and so far I haven't
hit upon the solution.
 
Bryce said:
Sorry but it doesn't. That's how I discovered the problem. I've tried
replacing the spaces with everything I could think of and so far I haven't
hit upon the solution.

How strange, because:

FtpSetCurrentDirectory(hConnect, "test dir");

Works absolutely fine for me on my XPSP2 box connecting to ftp server
running on same box.

Maybe you'd like to post code.
 
Back
Top