hi i am facing a weird problem. The scenario is that I have a folder that contains an image file. When the user upload another image file, then firstly the existing image file is renamed to x_Original.xxx and then the file to upload is uploaded(put) in the same directory with the name of the original file(the file that was renamed previously). example there is a file test.jpg in my ftp folder now when i upload another file newtest.jpg the following steps are taken: 1. the old file test.jpg is rename as test_original.jpg ( this is working fine ) 2. the new file is then put in the same folder, with the name test.jpg (i.e. the name of the old file) (this is creating a file with the name specified, but the filesize is 0kb and there is no content in the file).

The renaming is working flawlessly but when i put the new file after renaming old file, the new file is created but the contents of the image file are not saved. The new file that is created has 0kb size. Can you please elaborate if I am doing something wrong, or if i need to change something in my code ?

Note : please note that i m using the same instance of ftp object both for renaming and uploading file..

Many thanks

asked 16 Apr '10, 14:51

imran's gravatar image

imran
162
accept rate: 0%

edited 10 Aug '10, 13:29

Rebex%20KB's gravatar image

Rebex KB ♦♦
258519

A common cause of zero-length files appearing at the server after calling the PutFile method is supplying a MemoryStream (or other Stream) to the PutFile method whose current Position is set to the end-of-file. However without any code, we can't tell whether this is what happened or not. Would it be possible to post some code?

(16 Apr '10, 15:06) Lukas Pokorny ♦♦

Also, a log of communication between the FTP client and the server might reveal what is going on. Please check out http://forum.rebex.net/questions/10/how-to-create-a-log-of-communication-between-component-and-server for information about creating one. Then, either mail the log to us (support@rebex.net) or edit your question to include the relevant section of the log.

(16 Apr '10, 15:08) Lukas Pokorny ♦♦

many thanks for the quick reply

yes you were right, the stream of the file to be uploaded was set at the end. once it's position was set to 0, the put method is saving file on server successfully

once again, many thanks for the reply

(19 Apr '10, 12:53) imran

Thanks! I'm glad we got this solved. I will now re-post my comment as answer to make it possible for the others to find this solution as well!

(20 Apr '10, 10:20) Lukas Pokorny ♦♦
Be the first one to answer this question!
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
×16
×3

Asked: 16 Apr '10, 14:51

Seen: 1,144 times

Last updated: 23 Mar '11, 06:22