I have been looking at this for a while and I can't seem to get it. I have to get a string from one form to another but it doesn't work, I tried using get but it just threw that "get" didn't exist in this context. Here is my code. This is on the main form:
public string SavePoint()
{
string settings = "";
string archive = "";
if (rb_Backup.Checked)
{
settings = "backup";
}
else if (rb_Restore.Checked)
{
settings = "restore";
}
else if (rb_Sync.Checked)
{
settings = "sync";
}
if (cb_Archive.Checked)
{
archive = "true";
}
else
{
archive = "false";
}
string savePoint = txt_From.Text + "\r\n" + txt_To.Text + "\r\n" + settings + "\r\n" + archive;
return savePoint;
}
And this is on the form that is trying to access the data:
private void btn_Save_Click(object sender, EventArgs e)
{
frm_Main mainForm = new frm_Main();
string saveData = mainForm.SavePoint();
string savePath = AppDomain.CurrentDomain.BaseDirectory + "\\Profiles";
if (!Directory.Exists(savePath))
{
Directory.CreateDirectory(savePath);
}
StreamWriter saveFile = new StreamWriter(savePath + "\\" + txt_Save.Text + ".txt");
saveFile.WriteLine(saveData);
saveFile.Close();
this.Close();
}
I am learning which is one of the reasons I'm making this software.
Kindest regards,
Scobbo