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

GCDeveloper

Parent folder on SFTP being automatically created in local folder

How do I stop the parent folder of a file being downloaded from SFTP being created locally? Here is a snippet of my code.
var sFtppath = "./Solutions/Inbound/";
var sNetpath = @"\\Solutions\Inbound\";
...
using (_oSession)
{
    TransferOptions transferOptions = new TransferOptions
    {
        FileMask = "*.txt",
        TransferMode = TransferMode.Automatic
    };
 
    try
    {
        TransferOperationResult operationResult =
            _oSession.GetFiles(
               sFtppath,
               sNetpath + "*",
               false,
               transferOptions);
 
        operationResult.Check();
 
        foreach(TransferEventArgs transfer in operationResult.Transfers)
        {                       
            var tmp = transfer.FileName;
            _oSession.MoveFile(tmp, tmp + ".processed");
        }
...

The result I get looks like: /Solutions/Inbound/1579952381-20220902-022723.txt downloaded to \\Solutions\Inbound\Inbound\1579952381-20220902-022723.txt

The second Inbound in the destination is automatically created. How do I stop this? Doesn't make sense to me since my destination variable is explicitly clear, i.e.
sNetpath = @"\\Solutions\Inbound\"