gregasm
asked on
TextWriter not writing everything
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);
writer.Write(reader.ReadTo End());
writer.Close();
param = Convert.ToBase64String(mem Stream.ToA rray();
And here is the code that reads the base64 string back to text (xml):
public string Add(string Base64Binary)
{
try
{
MemoryStream memStream = new MemoryStream(Convert.FromB ase64Strin g(Base64Bi nary));
TextReader reader = new StreamReader(memStream);
string temp = reader.ReadToEnd();
FileStream strm = new FileStream(Server.MapPath( Guid.NewGu id().ToStr ing() + ".xml"), FileMode.Create, FileAccess.Write);
TextWriter writer = new StreamWriter(strm);
writer.Write(temp);
strm.Close();
return "Ack";
}
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!
Here is the code that creates the base64 string:
MemoryStream memStream = new MemoryStream();
TextWriter writer = new StreamWriter(memStream);
TextReader reader = new StreamReader(this.txtPath.
writer.Write(reader.ReadTo
writer.Close();
param = Convert.ToBase64String(mem
And here is the code that reads the base64 string back to text (xml):
public string Add(string Base64Binary)
{
try
{
MemoryStream memStream = new MemoryStream(Convert.FromB
TextReader reader = new StreamReader(memStream);
string temp = reader.ReadToEnd();
FileStream strm = new FileStream(Server.MapPath(
TextWriter writer = new StreamWriter(strm);
writer.Write(temp);
strm.Close();
return "Ack";
}
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am gonna try this first thing tomorrow morning.. THANKS MAN! I have a good feeling about this one hehehe
You should. I actually tested the code for once. ;)
ASKER
Thank you! I knew it was some "mundane detail" (from office space). =]]
Proper use of "flair" will often overcome those "mundane details".
ASKER
Hahah, dfiala13 you're a cool guy. =]]
ASKER
and smart! 153003 pts in one month! ! dang. you've got lots of flair. =]
blush, blush
TextWriter writer = new StreamWriter(strm);
writer.Write(temp);
writer.Flush();
strm.Close();