0 votes
by (160 points)
edited

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

Applies to: Rebex FTP/SSL
by (147k points)
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?
by (147k points)
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.

1 Answer

0 votes
by (160 points)

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

...