0 votes
by (290 points)
edited

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
by (1.0k points)
edited
 
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());
}
by (290 points)
Hi, Thanks for reply.It works for me. Shwetamber Chourey India
...