I'm getting error on sftp.GetFileList(ftpHost)
with message "No such file".
Using the given IP and credentials I've tested they have permissions to all the directories I'm connecting to.
string FileName = Label6.Text;
string rootPath = Server.MapPath("~");
string FolderName = "\\DL" + DateTime.Now.ToString("yyyyMMddHHmmss");
System.IO.Directory.CreateDirectory(rootPath + FolderName);
string rootPath1 = rootPath + FolderName;
string ftphost = "***.***.***.***";
string ftpfullpath = "ftp://" + ftphost + FileName;
int port = 22;
Sftp sftp = new Sftp("***.***.***.***", "@!#^@!^$", "!@#^#@#^&");
sftp.Connect(port);
sftp.GetFileList(ftphost);
ArrayList res = sftp.GetFileList(ftphost);
foreach (var item in res)
{
if (item.ToString() != "." && item.ToString() != "..")
Debug.WriteLine(item.ToString());
}
sftp.Get(ftpfullpath, rootPath1);
Also the account used to connect to the FTP has a script on it that puts it into a specific directory, is it necessary to somehow redirect the Get
or GetFileList
to the root?
GetFileList
method accepts a path to retrieve a listing for. Not hostname. You have specified the hostname in Sftp
constructor already.Get
method.ftp://
prefix?GetFileList
twice.