我是新的Windows窗體應用程序我想將數據保存在除(Sql)或數據庫以外的文件中。我嘗試了很多東西,並且只能使用它存儲文本文件中的一個值數據保存在除數據庫以外的文件中
TextWriter txt = new System.IO.StreamWriter("E:\\Tahir\\ScaleSystemDataSave\\First.txt");
txt.Write(txtFirsrWeight.Text);
txt.Close();
但我想保存的對象,在文件我怎麼能做到這一點。我的目標是這樣的
private void btnSave_Click(object sender, EventArgs e)
{
FirstTime obj = new FirstTime();
obj.CardNo = txtCardNo.Text;
obj.DateTime = txtDateTimePicker.Value;
obj.VehicleNo = txtVehicalNo.Text;
obj.WeightType = Convert.ToString(cbxWeigtType.SelectedItem);
obj.FirstWeight = txtFirsrWeight.Text;
if (rbtWithDriver.Checked == true)
{
obj.IsDriver = (int)Status.WithDriver;
}
else if (rbtWithouDriver.Checked == true)
{
obj.IsDriver = (int)Status.withOutDriver;
}
}
你需要從文本文件檢索數據並重新創建隨時對象? – Wheels73
請不要**標記爲垃圾郵件。標籤具有特定的含義,並在此處相關。使用實際適用於你的問題的那些。你的問題與JavaScript,PHP,CSS或OOP完全無關,所以**這些標籤都不適用於你的帖子**,並且添加它們是完全錯誤的。 –
好的謝謝先生幫助我提高我提問的能力 –