Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martinoooooooos

fixed

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.

Thanks
MArtinos
martinoooooos

wildcard not working with GetFiles

Hello,

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
                Console.WriteLine("Connecting...");
                session.Open(sessionOptions);

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

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

                transferResult  = session.GetFiles(remotePath, localPath, true);
                transferResult.Check();
                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)

Thanks
MArtinos