我正在使用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) –