I can download a file without any issues from FTP but cannot upload a file from local to FTP. I have changed it to blackslash and forward slashes on address path but still have the same error.
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();
If you're using one "/" without disabling the escape sequence, you're string won't be interpreted properly.
Try it with
string _ftpDirectory = @"/home/root/systools/WM";
or
string _ftpDirectory = "//home//root//systools//WM";
You can read more about escape sequences here
I believe you have an addional blank in your local directory variable:
string LocalDirectory = " E:\\charan\\final test\\WebMobility.db";
change it to
string LocalDirectory = "E:\\charan\\final test\\WebMobility.db";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.