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

asked 21 Sep '10, 13:17

Shwetamber's gravatar image

Shwetamber
282
accept rate: 0%


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());
}
link

answered 22 Sep '10, 12:19

Vit%20Zyka's gravatar image

Vit Zyka
912
accept rate: 8%

Hi,

Thanks for reply.It works for me.

Shwetamber Chourey

India

(23 Sep '10, 07:16) Shwetamber
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×152
×141
×15

Asked: 21 Sep '10, 13:17

Seen: 863 times

Last updated: 22 Sep '10, 12:19