TextWriter not writing everything
Posted on 2004-04-21
I have a webservice that takes a base64 encoded string and converts it to xml, and then writes it out to a file.
Here is the code that creates the base64 string:
MemoryStream memStream = new MemoryStream();
TextWriter writer = new StreamWriter(memStream);
TextReader reader = new StreamReader(this.txtPath.Text);
param = Convert.ToBase64String(memStream.ToArray();
And here is the code that reads the base64 string back to text (xml):
public string Add(string Base64Binary)
MemoryStream memStream = new MemoryStream(Convert.FromBase64String(Base64Binary));
TextReader reader = new StreamReader(memStream);
string temp = reader.ReadToEnd();
FileStream strm = new FileStream(Server.MapPath(Guid.NewGuid().ToString() + ".xml"), FileMode.Create, FileAccess.Write);
TextWriter writer = new StreamWriter(strm);
The thing is: The file, when I open it, seems to be truncated! Have any of you guys run into this problem before, and know what's going on? Thanks!