Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
FileInfo fi = new FileInfo("settings.txt");
StreamWriter sw = fi.CreateText();
sw.WriteLine("0;0;50;50;true");
sw.Write(sw.NewLine);
sw.close;
StreamReader sr = File.OpenText("settings.txt");
string[] settings;
string input = null;
int line = 0;
[green]// Read each line in the file[/green]
while ((input = sr.ReadLine()) != null)
{
line++;
settings = input.Split(';');
[green]// Do something different based on line[/green]
if (line == 1)
{
chkBox.Left = int.Parse(settings[0]);
chkBox.Top = int.Parse(settings[1]);
chkBox.Height = int.Parse(settings[2]);
chkBox.Width = int.Parse(settings[3]);
if (settings[4] == "true")
chkBox.Checked = true;
else
chkBox.Checked = false;
}
...
}
sr.close;
[Serializable]
public class MyForm
{
public int iConnection;
[NonSerialized] public Button btnLogin;
public string strConnection;
}
Next use the BinaryFormatter class to save the state:
MyForm frm = new MyForm();
Stream fs = File.Open("frm.bin", FileMode.Create, FileAccess.ReadWrite);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, frm);
fs.Close();
// Load
Stream fr = File.Open("frm.bin", FileMode.Open, FileAccess.Read);
BinaryFormatter bf = new BinaryFormatter();
MyForm frm2 = (MyForm) bf.Deserialize(fr);
fr.Close();