I use C# FtpClient library to upload a file. The connection is established after I set custom port 3072, because I set client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12
;
But when I am going to go through
client.GetFilePermissions("/Test.txt");
client.UploadFile(@"C:\Users\Desktop\Test.txt", "/Test.txt");
it will always shows exception
Unable to read data from the transport connection: An attempt was made to access a socket in a way forbidden by its access permissions.
If I turn Windows Firewall off, file can be uploaded successfully.
I want to know what policy should I set on Windows firewall to allow me touch remote file and upload it.
Current my firewall setting:
(Inbound)
Local port 3072,80,20,21,1023
Remote port 3072,80,20,21,1023(Outbound)
Local port 3072,80,20,21,1023
Remote port 3072,80,20,21,1023
My complete code
FtpClient client = new FtpClient();
client.Host = "xx.xx.xx.xx";
client.Credentials = new NetworkCredential(UserName, Password);
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
client.Connect();
if (client.IsConnected)
{
Console.WriteLine("Connected");
client.DataConnectionEncryption = true;
var resutl = client.GetFilePermissions("/Test.txt");
client.UploadFile(@"C:\Users\Desktop\Test.txt", "/Test.txt");
}
else
{
Console.WriteLine("No Connetion");
}