Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

C#
Posted

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.

C#
Posted
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?
C#
Posted

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();

}

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...