我在sftp.GetFileList(ftpHost)上收到错误消息“ No such file”。使用给定的ip和凭据,我测试了它们对我连接到的所有目录的权限。
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);
编辑:另外,用于连接ftp的帐户上有一个脚本,可将其放入特定目录中,是否有必要以某种方式将Get或GetFileList重定向到根目录?
GetFileList
方法接受用于检索列表的路径。不是主机名。您已经在Sftp
构造函数中指定了主机名。Get
方法。ftp://
前缀?GetFileList
两次。本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句