I try to upload files and wrote the following code with the help of FluentFTP:
clientFluentFTP = new FtpClient(hostname,
username,
password);
clientFluentFTP.LoadProfile(new FtpProfile
{
Host = hostname,
Credentials = new NetworkCredential(username, password),
Encryption = FtpEncryptionMode.Explicit,
Protocols = SslProtocols.Tls12,
DataConnection = FtpDataConnectionType.PASV,
Encoding = Encoding.UTF8,
}) ;
clientFluentFTP.ValidateAnyCertificate = true;
clientFluentFTP.Connect();
clientFluentFTP.UploadFile(localfile, requestname, FtpRemoteExists.Overwrite,false,FtpVerify.Throw);
I test with my first file (UTF8 encoded) and the result is a zero byte file. No exception is thrown so I assume it is able to verify the transfer. Apparently the transfer is not closed off correctly. And yes, with commandline FTP clients I can transfer the file without problems. No message, no error. Just a zero byte file.
What do I do wrong?
The Log from the code is below.
# Connect()
Status: Connecting to 46.235.40.106:21
Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
Response: 220-You are user number 3 of 50 allowed.
Response: 220-Local time is now 11:54. Server port: 21.
Response: 220-This is a private system - No anonymous login
Response: 220-IPv6 connections are also welcome on this server.
Response: 220 You will be disconnected after 15 minutes of inactivity.
Status: Detected FTP server: PureFTPd
Command: AUTH TLS
Response: 234 AUTH TLS OK.
Status: FTPS Authentication Successful
Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0,1315097.
Command: USER ***
Response: 331 User ftp_meteo_wagenborgen.nl OK. Password required
Command: PASS ***
Response: 230-Your bandwidth usage is restricted
Response: 230 OK. Current restricted directory is /
Command: PBSZ 0
Response: 200 PBSZ=0
Command: PROT P
Response: 200 Data protection level set to "private"
Command: FEAT
Response: 211-Extensions supported:
Response: EPRT
Response: IDLE
Response: MDTM
Response: SIZE
Response: MFMT
Response: REST STREAM
Response: MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
Response: MLSD
Response: AUTH TLS
Response: PBSZ
Response: PROT
Response: UTF8
Response: ESTA
Response: PASV
Response: EPSV
Response: SPSV
Response: ESTP
Response: 211 End.
Status: Text encoding: System.Text.UTF8Encoding
Command: OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Command: SYST
Response: 215 UNIX Type: L8
# UploadFile("utils/systeminfoTable.txt", "/web/systeminfoTable.txt", Overwrite, False, Throw)
# FileExists("/web/systeminfoTable.txt")
Command: SIZE /web/systeminfoTable.txt
Response: 213 1467
# DeleteFile("/web/systeminfoTable.txt")
Command: DELE /web/systeminfoTable.txt
Response: 250 Deleted /web/systeminfoTable.txt
# OpenWrite("/web/systeminfoTable.txt", Binary)
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
# OpenPassiveDataStream(PASV, "STOR /web/systeminfoTable.txt", 0)
Command: PASV
Response: 227 Entering Passive Mode (46,235,40,106,168,24)
Status: Connecting to 46.235.40.106:43032
Command: STOR /web/systeminfoTable.txt
Response: 150 Accepted data connection
Status: FTPS Authentication Successful
Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0,1381567.
Status: Disposing FtpSocketStream...
Status: File Verification: PASS
# Dispose()
Status: Disposing FtpClient object...
Command: QUIT
Status: Disposing FtpSocketStream...
Status: Disposing FtpSocketStream...