我已经看了一段时间了,我似乎无法理解。我必须将字符串从一种形式获取到另一种形式,但它不起作用,我尝试使用 get 但它只是抛出“get”在这种情况下不存在。这是我的代码。这是在主窗体上:
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;
}
这是在试图访问数据的表单上:
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();
}
我正在学习这是我制作这个软件的原因之一。
最亲切的问候,
斯科博