I have used FluentFTP
lib im my project to work with FTP via TLS, but some trouble here.
This code working fine:
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.CreateDirectory("/test/path/that/should/be/created", true);
}
And directory were created. But in other examples it not working good.
First exmple (logfile - https://pastebin.com/jNyZ3fmD):
public static void DownloadFile()
{
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.DownloadFile("localPath", "ftpPath", FtpLocalExists.Overwrite, FtpVerify.Retry);
}
}
I have error:
"Error while uploading the file to the server. See InnerException for more info." IOException: Authentication failed because the remote party has closed the transport stream
Trying to get file/dir-list from FTP using code below return nothing in console (logfile - https://pastebin.com/V8AiLs8k):
using (var conn = new FtpClient("adress", "user", "password"))
{
//conn.Connect();
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
conn.Connect();
// get a recursive listing of the files & folders in a specific folder
foreach (var item in conn.GetListing())
{
switch (item.Type)
{
case FtpFileSystemObjectType.Directory:
Console.WriteLine("Directory! " + item.FullName);
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
break;
case FtpFileSystemObjectType.File:
Console.WriteLine("File! " + item.FullName);
Console.WriteLine("File size: " + conn.GetFileSize(item.FullName));
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
Console.WriteLine("Chmod: " + conn.GetChmod(item.FullName));
break;
case FtpFileSystemObjectType.Link:
break;
}
Console.WriteLine(item);
}
}
The user has the privilege to download, create and delete files. But I can only make a dir on server.