WriteTo function in .NET MemoryStream NOT properly documented
2 06 2006
I've spent 12 hrs trying to upload address as a formatted XML file to MelissaData for address verification, correction, and geocoding. I just figured out the problem! The WriteTo function writes from the CURRENT cursor position to the end of the stream. Well, thats not what the documentation says. It says it writes the WHOLE stream. I've spent hours writing & rewriting code and porting code back and forth between C# & VB.NET. The sample code was in C# but I already had some data handling functions for my data in VB so I stayed with that. But it didn't work, so I thought maybe I'm missing a small step and I combined my intial data handling and thier WebRequest/Response code together in C#. I couldn't use thier code exactly but it was very close, only instead of writing the XML to a binary array, I was either writing it to a file or directly to the memory stream. I even thought, well maybe I'm just not properly tranforming the tags to the EXACT right stuff. So I tried ALL of the XML serialization methods presented here. Still no results from the web service. I had been writing the XML to both a file & the memory stream & then checking the file to make sure all tags were closed & formated correctly, etc.. I finnally decided to use the WriteTo function to write to a MessageBox rather that the RequestStream. What comes up in the box? NOTHING, because it is at EOS. Seek the cursor back to the begining and viola a valid response is finnaly recieved!! That was about 10hrs in front of a computer and several more thinking about the problem I could have avoided, if MS would have put those few more words in the documentation for the WriteTo function. Oh well, I now am very good at creating XML documents, querying them, and modifying them in a vareity of methods and I'm much more confindent in my C# writing abilities, so I'll chalk it all up to a learning experience.

Thank you!!
Worked on the same exact issue for a day and was growing (new) gray hair!!
This is not the only example of bad documentation in .NET, unfortunately.
Thanks!
You’ve saved my day, thank you!
I’ve spend hours trying to read/write data from virtual memorystream. Finally I found your hint and now everything works fine.
Chris