Hello,
I'm building a application that uses a file to configure some fonts. It's like this:
Font = Verdana
Size = 12
Style = Bold
And my code is like this:
openDialog.ShowDialog();
string file = openDialog.FileName;
StreamReader reader = new StreamReader(file);
while (reader.Peek() <= 0)
{
string line = reader.ReadLine();
string[] data = Split(new[] { '=' });
// property is in data[0]
// value is in data[1]
TextFont = data[1];
TextSize = data[3];
TextSt = data[5];
}
reader.Close();
reader.Dispose();
And using it like this:
textBox1.Font = new System.Drawing.Font(TextFont, 12F, FontStyle.Bold);
But when I execute it I got this error:
ArgumentException
Value does not fall within the expected
Then I have two questions:
- How can I solve this problem?
- How can I use instead of a string for
TextSize
use a float to implement it in theFont
method?
Thanks.