aewarnick Posted February 10, 2003 Posted February 10, 2003 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? Quote C#
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 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. Quote C#
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 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? Quote C#
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 Do I even have to use Serialize and Deserialize to read and write to and from files? Quote C#
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 Why doesn't 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(); } Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.