ftp上传错误:“不支持给定路径的格式。”

时间:2014-09-25 08:24:34

标签: c# ftp

我可以从FTP下载文件而不会出现任何问题但无法将文件从本地上传到FTP。我已将其更改为地址路径上的黑色斜杠和正斜杠,但仍然有相同的错误。

 string _ftpURL = @"192.168.0.134";
 string _UserName = "root"; //User Name of the SFTP server
string _Password = "porter"; //Password of the SFTP server
int _Port = 2222; //Port No of the SFTP server (if any)
string _ftpDirectory = "/home/root/systools/WM"; //The directory in SFTP server where the files will be uploaded
string LocalDirectory = " E:\\charan\\final test\\WebMobility.db"; //Local directory from where the files will be uploaded
Sftp Connection = new Sftp(_ftpURL, _UserName, _Password);
Connection.Connect(_Port);
**Connection.Put(LocalDirectory, _ftpDirectory);**
Connection.Close();

2 个答案:

答案 0 :(得分:0)

如果您在不禁用转义序列的情况下使用一个“/”,则无法正确解释字符串。
尝试使用

string _ftpDirectory = @"/home/root/systools/WM";  

string _ftpDirectory = "//home//root//systools//WM";

您可以阅读有关转义序列here

的更多信息

答案 1 :(得分:0)

我相信你的本地目录变量还有一个空白:

string LocalDirectory = " E:\\charan\\final test\\WebMobility.db";

将其更改为

string LocalDirectory = "E:\\charan\\final test\\WebMobility.db";
相关问题