Hi every body
I'm trying to write an phone book application and want to let the user to select the font for browsing its contacts ,and want to store the information
about that font in a file then retrieving it at form load when loading the application
i try the folowing to stotre my information
Code:
FileStream file = new FileStream("setting.dat", FileMode.Create, FileAccess.Write);
BinaryWriter binwriter = new BinaryWriter(file);
//for saving tags colors
for(int x=0;x<6;x++)
{
binwriter.Write(clrIntArray[x]);
}
//for storing font informations
binwriter.Write(mainDataGrd.DefaultCellStyle.Font.Name);
binwriter.Write(mainDataGrd.DefaultCellStyle.Font.Size);
file.Close();
and for loading my information
Code:
FileStream file = new FileStream("setting.dat", FileMode.Open, FileAccess.Read);
int[] clrIntArray = new int[6];
BinaryReader binReader = new BinaryReader(file);
//for reading tags colors
for (int x = 0; x < 6; x++)
{
clrIntArray[x] =binReader.ReadInt32();
}
//for reading font info
string fn = binReader.ReadString();
float sz= (float)binReader.ReadDouble();
file.Close();
mainDataGrd.DefaultCellStyle.Font = new System.Drawing.Font(fn,sz);
the problem is when i try to read the file for restoring myinfo i got exception error its syntax =-->
"unabel to read beyond the end of the stream "
and i don't know why.
could any one help and if there a better way for storing the font than mine i will appreciate