Squares and Y's with dots on top

aewarnick

Well-known member
Joined
Jan 29, 2003
Messages
1,031
private void SaveB_Click(object sender, System.EventArgs e)
{
string FormData=GetData();
string f="CommLog\\"+DateTime.Now.ToShortDateString()+".txt";
f=f.Replace("/","_");
MessageBox.Show(FormData);
output=new FileStream(f, FileMode.OpenOrCreate, FileAccess.ReadWrite);
writeIt.Serialize(output, FormData);
}

Why do I get a whole bunch of silly characters in my text file when I save it to disk?
 
I cannot convert my stream to a type NewLog just like my book says.

private void ReadIt()
{
string f="CommLog\\2_9_2003.txt";
stream=new FileStream(f, FileMode.Open, FileAccess.Read);
NewLog Log=(NewLog)reader.Deserialize(stream);
}

I always get the error message about not being able to convert it.
 
I did notice in the book that NewLog is just an object class. Not a form and it says [Serializable] at the top. Do I have to do some major modification by putting all my code in another place?
 
Why doesnt Deserialize put the text into x?

private void ReadIt()
{
string x="";
string file="CommLog\\2_10_2003.txt";
stream=new FileStream(file, FileMode.Open, FileAccess.Read);
x=(string)reader.Deserialize(stream);
this.richTextBox1.Text+=x;
stream.Close();
}
 
Back
Top