Ftp.PutFile() Method upload the file but always return 0.0

0 votes
asked Sep 21, 2010 by Shwetamber (290 points)
edited Sep 22, 2010

Hi,

I am using Ftp.PutFile() method for upload single file. This method always return 0.0 value. Either file upload successfully or not. I could not recognize file transfer done successfully or not.

Can anyone suggest me about this problem ?

Thanks & regards
Shwetamber Chourey
India

Applies to: Rebex FTP/SSL, Rebex SFTP

1 Answer

0 votes
answered Sep 22, 2010 by Vit Zyka (1,000 points)
edited Sep 22, 2010
 
Best answer

Hello,

zero of transmitted bytes (return value of PutFile) is not an indicator of unsuccessful transfer. If a transfer is unsuccessful the exception is thrown. According to both the exception Status and/or the Message properties you can detect the error reason.

When no exception occurs then the transfer is successful and the return value indicates the number of bytes transmitted.

Following code can show you what it really happens.

try
{
  long bytesTransmitted = ftp.PutFile(file);
  Console.WriteLine("Transmitted {0} bytes.", bytesTransmitted);
}
catch(exception ex)
{
  Console.WriteLine("Transfer error. Stack trace:\n{0}\n", ex.ToString());
}
commented Sep 23, 2010 by Shwetamber (290 points)
Hi, Thanks for reply.It works for me. Shwetamber Chourey India
...