Click here to Skip to main content
15,901,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am doing project of global recycle bin in c#when i am transfer file from client to server or restoring it file transfer less than actual size of file why this happend? what should i do to handle this?
Posted
Comments
Sandeep Mewara 23-Apr-11 9:31am    
It would be difficult for anyone to comment without seeing the piece of code you are using.

Update the question with the code snippet. (Use Improve Question link)

1 solution

You may find this is due to the protocol (possibly ftp or less likely tcp) splitting the file transfer into packets. If this coccured your code may need to read from the stream (that I presume you are using) to transfer to the file to actually read the entire file from the stream. A loop similar to:

int BytesRead = Stream.Read(...);
while(BytesRead > 0)
{
BytesRead = Stream.Read(...);
}


then whatever you use as your buffer in the Stream.Read method will contain all the file bytes rather than just some of them. A good check is also to check if your buffer contains the number of bytes you expected.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900