Post a reply

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)


Topic review


There's no .Count. There's .Count() extension method. For that you need:
using System.Linq;

I see examples like this one where you get the count but when I type in .Count it is not accepted as good code. How do you make it so that .Count shows up as an option? (see attached image) This may sound like an elementary question but I am not a professional programmer. Just trying to piece things together. Thanks.
int directoriesCount = session.EnumerateRemoteFiles(
    sftpFolder, "*.xml", EnumerationOptions.None).Count;

Re: error using move file when folder is empty

The Session.MoveFile can move a single file only. Indeed, it works with a file mask, but that was never intended and is a kind of a bug. If you want to use a file mask, you should use Session.EnumerateRemoteFiles and use Session.MoveFile for each found file.

error using move file when folder is empty

I am using this C# code to move files:
session.MoveFile("/parcs/download/PNB/*.xml", "/parcs/download/PNB/Processed/");

It works fine unless the folder is empty then I get this error.

Message:/parcs/download/PNB/*.xml not found.;
Base Exception:WinSCP.SessionRemoteException: /parcs/download/PNB/*.xml not found.
at WinSCP.Session.MoveFile(String sourcePath, String targetPath)
at RppGLUpdate.Class1.Main(String[] args).

How do I fix this so that it is okay with an empty folder?