我正在使用C#的Winforms應用程序,並希望添加一個保存功能的幾個部分,用戶將打包輸入文本到文本框,並將其保存下一次。如何在winforms應用程序中保留文本數據?
這是如何在winforms中實現的? 我正在嘗試一個本地xml文件,並且無法讀取它時仍然保留文本。 data.xml是我的項目根文件夾中的本地文件。
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"(full path)\visual studio 2015\Projects\My_helper\data.xml");
string subject = xmlDoc.DocumentElement.SelectSingleNode(@"./content/reminder_email/subject").InnerText.ToString();
string body = xmlDoc.DocumentElement.SelectSingleNode(@"./content/reminder_email/body").InnerText.ToString();
如果只有很少的東西要保存我會建議你使用[屬性設置](https://stackoverflow.com/questions/650555/how-to-use-settings-in-visual-c-sharp ) –
什麼應該是你的xml的結構,並且你想在哪個節點上保存數據?看看[這個SO](https://stackoverflow.com/questions/9616163/c-sharp-modify-a-xml-node)或[this SO](https://stackoverflow.com/questions/ 16806838/how-to-update-xml-nodes-with-new-values)? –
[C#:Modify a xml node]可能重複(https://stackoverflow.com/questions/9616163/c-sharp-modify-a-xml-node) –