Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FTP server - directory name has spaces

9 views
Skip to first unread message

Dave Calkins

unread,
May 27, 2006, 8:23:01 AM5/27/06
to
I'm attempting to find and remove a bunch of files from an FTP server which
match a specified pattern. The problem I'm having is that the directory on
the server contains a space in the name.

I'm using the MFC WinInet wrapper classes to make use of the API. So, my
code looks like the following:

CInternetSession inetSession;
CFtpConnection * pConnection = NULL;
pConnection =
inetSession.GetFtpConnection(oc->server,oc->userName,oc->password);
CFtpFileFind finder(pConnection);
CStringArray filesToDelete;
BOOL bWorking = finder.FindFile(oc->fileNames);
while (bWorking)
{
bWorking = finder.FindNextFile();
filesToDelete.Add(finder.GetFilePath());
}

What is the correct way to deal with this? I've tried using the following
as arguments to the FindFile() method which do not appear to work.

My?Stuff
My\ Stuff
My*Stuff


Dave Calkins

unread,
May 30, 2006, 4:44:01 PM5/30/06
to
fyi, I discovered that the WinInet API called by the MFC classes for finding
files on an FTP server assumes no spaces in the file pattern argument
(according to the MSDN documentation for the API).

I've been able to work around the issue as follows. It turns out you can
change the working directory to a directory which contains spaces. So, I
pull off the directory portion of the string and change the working directory
to that directory. Once there, I use the find function on the file pattern.

For example, assuming the file pattern to remove looks like the below:

"/a/b/c/My Stuff/data*.exe"

I first change the working directory to "/a/b/c/My Stuff" and then use the
find on "data*.exe".

The limitation this workaround introduces is that the wildcards can only be
in the filename part not the directory path portion. So you can't do
"/a/b*/c/My Stuff/data*.exe", for example.

0 new messages