Topic "wildcard not working with GetFiles"

Author Message



This is really crazy and it should be working as it is mostly code directly from the documentation.

But here we go. I am trying to use getFiles with the remove parameter on. What i want to do is retrieve all files from a remote location and then delete the files once successful without deleting the folder. I found that doing it after the getFiles by traversing the list returned is a bit inefficient so then i gave the remove variable true which is way more efficient except it removes the folder as well.

The following code based on the documentation should work, but doesn't. Any help is appreciated


            using (Session session = new Session())
                //session.SessionLogPath = sessionLogPath;

                // Connect

                TransferOptions transferOptions = new TransferOptions();
                transferOptions.TransferMode = TransferMode.Binary;
                TransferOperationResult transferResult;

                var remotePath = "/" + ftpFolder [b]+ "/*" ;[/b]

                transferResult  = session.GetFiles(remotePath, localPath, true);
                Console.WriteLine("Finished sending files for " + ftpFolder);

If i leave teh wildcard and the slash from above:
var remotePath = "/" + ftpFolder
the whole thing works perfectly except it deletes the folder at the end.

If i leave the wildcard only
var remotePath = "/" + ftpFolder + "/" ;

Then it correctly deletes all the files but then gets in an infinite loop where its looking for new files constantly to move and never ends the GetFiles method.

I am using the latest version(5.9.3)



I have resolved my own questions.

It was picking the local folder as a file for some reason so it needed an extra slash at the end.

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26299
Location: Prague, Czechia
martinoooooooos wrote:
It was picking the local folder as a file for some reason so it needed an extra slash at the end.

As documented:

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License