Yes, actually I didn't quote the path initially, but it didn't work. Then I tried to quote the path still no help.
Here is my code after removing the quote, and attached is the log.
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
//Protocol = site.Type == "FTP" ? Protocol.Ftp : Protocol.Sftp,
HostName = "xxx.xx.xxx.xx",
UserName = "FTPUser",
Password = "Password",
PortNumber = 21,
Protocol = Protocol.Ftp
};
using (Session session = new Session())
{
try
{
// Connect
session.SessionLogPath = "e:\\temp\\ftp.log";
session.Open(sessionOptions);
var remoteFileInfos = session.EnumerateRemoteFiles("/Inbox/csv", "*.csv", EnumerationOptions.None)
.Where(file => !file.IsDirectory)
.OrderByDescending(file => file.LastWriteTime);
foreach (var remoteFileInfo in remoteFileInfos)
{
var remoteFile = session.EscapeFileMask(String.Format("{0}", remoteFileInfo.FullName));
var localFile = Path.GetFullPath(String.Format("e:\\temp\\{0}", remoteFileInfo.Name));
if (!remoteFileInfo.Name.IsNullOrEmpty())
{
//var transOptions = new TransferOptions();
//transOptions.FileMask = remoteFileInfo.Name;
session.GetFiles(remoteFile, localFile,false).Check();
var archiveFilePath = session.EscapeFileMask("/Inbox/Backup" + "/" + remoteFileInfo.Name);
if (session.FileExists(archiveFilePath))
session.RemoveFiles(archiveFilePath);
session.MoveFile(remoteFile, archiveFilePath);
}
}
session.Close();
}
catch (Exception ex)
{
session.Dispose();//Release session
txtOutput.Text = $"{ex.Message}\r\n{ex.StackTrace}";
}
// Download the selected file
}
martin wrote:
You seem to have tried to quote the path somehow. Did you? What is your code like?
Use just a simple path, no quoting. If that does not work, post a log file for that.
-
ftp.log (7.53 KB, Private file)