Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.6k views
in .NET FTP by (300 points)
I have the FTPConnector connecting and transferring files to a local ftp server.
However the file that get transferred always miss off a few KB from the original file so I'm not able to open the new file on the ftp server.

I have tried changing the transferType and ConnectionMode options, but seems to make no difference at all. This happens to all file types. I have included the log below. Any ideas/help would be appreciated.
Thanks.

DEBUG [FTPControlSocket] 2 Feb 2007 16:00:14.328 : NewPassiveDataSocket(192.168.1.49,3270)
DEBUG [FTPControlSocket] 2 Feb 2007 16:00:14.328 : ---> STOR cms1.dmp
DEBUG [FTPControlSocket] 2 Feb 2007 16:00:14.328 : 125 Data connection already open; Transfer starting.
ALL [FTPConnection] 2 Feb 2007 16:00:14.328 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler
ALL [FTPConnection] 2 Feb 2007 16:00:14.328 : Have GUI control
ALL [FTPConnection] 2 Feb 2007 16:00:14.328 : GUI control invocation not required
ALL [FTPConnection] 2 Feb 2007 16:00:14.468 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler
ALL [FTPConnection] 2 Feb 2007 16:00:14.468 : Have GUI control
ALL [FTPConnection] 2 Feb 2007 16:00:14.468 : GUI control invocation not required
ALL [FTPConnection] 2 Feb 2007 16:00:14.468 : Invoking delegate dynamically
ALL [FTPConnection] 2 Feb 2007 16:00:14.468 : Dynamic delegate invocation complete
WARN [FTPClient] 2 Feb 2007 16:00:16.718 : Caught exception flushing output-stream : System.ArgumentException: Found a low surrogate char without a preceding high surrogate at index: 880.  The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters.
Parameter name: chars at System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, UTF8Encoderencoder)
   at System.Text.UTF8Encoding.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, UTF8Encoder encoder)
   at System.Text.UTF8Encoder.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Flush()
   at EnterpriseDT.Net.Ftp.FTPClient.PutASCII(Stream srcStream, String remoteFile, Boolean append, Boolean alwaysCloseStreams)

ALL [FTPConnection] 2 Feb 2007 16:00:16.750 : Invoking delegate EnterpriseDT.Net.Ftp.FTPFileTransferEventHandler
ALL [FTPConnection] 2 Feb 2007 16:00:16.750 : Have GUI control
ALL [FTPConnection] 2 Feb 2007 16:00:16.750 : GUI control invocation not required
ALL [FTPConnection] 2 Feb 2007 16:00:16.750 : Invoking delegate dynamically
ALL [FTPConnection] 2 Feb 2007 16:00:16.750 : Dynamic delegate invocation complete
ALL [FTPConnection] 2 Feb 2007 16:00:16.765 : Invoking delegate EnterpriseDT.Net.Ftp.FTPConnectionEventHandler
ALL [FTPConnection] 2 Feb 2007 16:00:16.765 : Have GUI control
ALL [FTPConnection] 2 Feb 2007 16:00:16.765 : GUI control invocation not required
ALL [FTPConnection] 2 Feb 2007 16:00:16.765 : Invoking delegate dynamically
ALL [FTPConnection] 2 Feb 2007 16:00:16.765 : Dynamic delegate invocation complete
DEBUG [FTPControlSocket] 2 Feb 2007 16:00:16.765 : ---> QUIT
DEBUG [FTPControlSocket] 2 Feb 2007 16:00:16.765 : 226 Transfer complete.

5 Answers

0 votes
by (300 points)
Just to update. I have been doing further testing it doesn't pick up on the Surrogate Char anymore. It does say that File successfully transferred as per the log below. However on each occasion the uploaded file is around 10KB less than the original. I've spend days getting this far I don't want to scrap this.

In this log file it is saying Uploaded 315KB. But the original file is 326KB.

ALL [FTPConnection] 2 Feb 2007 17:39:41.823 : Have GUI control
ALL [FTPConnection] 2 Feb 2007 17:39:41.823 : GUI control invocation not required
ALL [FTPConnection] 2 Feb 2007 17:39:41.823 : Invoking delegate dynamically
ALL [FTPConnection] 2 Feb 2007 17:39:41.823 : Dynamic delegate invocation complete
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:42.203 : 226-File successfully transferred
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:42.203 : 226 21.046 seconds (measuredhere), 14.92 Kbytes per second
ALL [FTPConnection] 2 Feb 2007 17:39:42.203 : Invoking delegate EnterpriseDT.Net.Ftp.FTPFileTransferEventHandler
ALL [FTPConnection] 2 Feb 2007 17:39:42.203 : Have GUI control
ALL [FTPConnection] 2 Feb 2007 17:39:42.203 : GUI control invocation not required
ALL [FTPConnection] 2 Feb 2007 17:39:42.203 : Invoking delegate dynamically
ALL [FTPConnection] 2 Feb 2007 17:39:42.203 : Dynamic delegate invocation complete
ALL [FTPConnection] 2 Feb 2007 17:39:42.203 : Dynamic delegate invocation complete
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:42.213 : ---> TYPE I
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:42.544 : 200 TYPE is now 8-bit binary
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:42.544 : ---> CWD /htdocs/test
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:42.944 : 250 OK. Current directory is/htdocs/test
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:42.944 : ---> PWD
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:43.315 : 257 "/htdocs/test" is your current location
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:43.315 : ---> QUIT
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:43.665 : 221-Goodbye. You uploaded 315 and downloaded 0 kbytes.
DEBUG [FTPControlSocket] 2 Feb 2007 17:39:43.665 : 221 Logout.
0 votes
by (162k points)
Have you downloaded the file again to a different filename & checked to see if the files are identical?
0 votes
by (300 points)
What I did was this:
Uploaded file test.doc to the ftp server with the name test.doc.
When I download the file from the ftp server locally and compare to the original, it is always around 10-20KB smaller.
Cannot open the document either as it gets corrupted. I have put so much time into this, but I'm all out of ideas as to what to do next. Can you suggest anything please?
0 votes
by (162k points)
I'm assuming you are transferring in binary mode for both upload & download?
0 votes
by (300 points)
Yes, I was doing it in Binary, but also tried ASCII too, just to check.

Here is the code I'm using.

This bit is in the form load event.
ftp.AutoLogin = true;
ftp.TransferType = EnterpriseDT.Net.Ftp.FTPTransferType.BINARY;
ftp.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.PASV;
ftp.ServerAddress = ConfigurationSettings.AppSettings["FTPServer"].ToString();
Logger.CurrentLevel = Level.ALL;
ftp.UserName = ConfigurationSettings.AppSettings["FTPUser"].ToString();
ftp.Password = ConfigurationSettings.AppSettings["FTPPass"].ToString();


The following bits of code are in their relevent events as shown.

private void ftp_BytesTransferred(object sender, EnterpriseDT.Net.Ftp.BytesTransferredEventArgs e)
{
   textBox2.Text = e.ByteCount.ToString();
   Application.DoEvents();
}



private void ftp_LoggedIn(object sender, EnterpriseDT.Net.Ftp.FTPLogInEventArgs e)
{
try
{
   if (ftp.IsConnected)
   {
      string sfile = ConfigurationSettings.AppSettings["ListOfSQLCommandsDBFile"].ToString(); 
      ftp.ChangeWorkingDirectory(ConfigurationSettings.AppSettings["RemoteFolder"].ToString());
      ftp.UploadFile(sfile,ConfigurationSettings.AppSettings["ListOfSQLCommandsDBFile"].ToString());
   }
}
catch(Exception ex2)
{ErrorLog()}

Categories

...