In order to achieve the purpose of temporary storage data, I chose app.config.
This article assumes that the pre-set content of app.config is as follows:
XML Version = "1.0" encoding = "UTF-8"?>
I don't say it, many people will!
Quote: Imports System.configuration Name Space
then,
Tbcopy.text = configurationSettings.appsettings ("copy") TBCompany.text = configurationSettings.appsettings ("Company") TBComurl.Text = ConfigurationSettings.AppSettings ("Comurl")
This is called!
But how can I edit? How to edit it into a problem, first find a long time on 9CBS, no fruit, I have been looking for it for a long time to MSDN, not suitable, it seems that I have to do it! Because it is a typical XML file, it can operate it with XML! Place the following process in the module or where you need it!
===
VB.NET
===
Public Sub SysConfig (ByVal myValue () As String) Dim i As Integer Dim XmlDoc As New XmlDocument XmlDoc.Load (Application.ExecutablePath & ".config") Dim XN As XmlNode = XmlDoc.SelectSingleNode ( "/ configuration / appSettings") For i = 0 To myValue.Length - 1 XN.ChildNodes.Item (i) .Attributes.ItemOf (1) .Value () = myValue (i) Next xmlDoc.Save (AppDomain.CurrentDomain.SetupInformation.ConfigurationFile) XmlDoc = Nothing End Sub
===
C # .NET
===
Public void sysconfig (String MyValue ())
{Xmldocument xmldoc = new xmldocument ();
XMLDoc.Load (Application.executablePath & ".config"); XMLNode XN = New XMLNode (); xn.selectsinglenode ("/ configuration / appsettings"); for (int i = 0; i <= myValue.length - 1; i )
{Xn.childnodes.Item (i) .attributes.Itemof (1) .value () = MyValue (i);
} Xmldoc.save (appdomain.currentdomain.setupinformation.configurationfile); xmldoc.dispose ();
}
I am using a string array to make parameters! Each value is a line in config! Route it in order!
DIM TMPSTR () AS String = {Trim (Tbcopy.Text), Trim (TBCompany.Text), Trim (TBComurl.Text)} Sysconfig (Tmpstr)
This completes the purpose of the revision!
There is also a method:
Read Write CONFIG and related XML files in DataSet, Private Sub DEALXML () Dim myds as new dataset myds.readXML (AppDomain.currentDomain.setupinformation.configurationFile) TBCopy.Text = myds.tables (1). ROWS (0) (1) Tbcompany.text = myds.tables (1) .ROWS (1) (1) TbcomURL.Text = myds.tables (1) .ROWS (2) (1) '------------- ----------------------------- Myds.tables (1) .ROWS (0) (1) = tbcopy.text myds.tables (1) .ROWS (1) (1) = tbcompany.text myds.tables (1) .ROWS (2) (1) = tbcomurl.text '---------------- -------------------------- myds.acceptchanges () myds.writexml (appdomain.currentdomain.setupinformation.configurationfile) myds.clear () MyDS. Dispose () end sub
As for which kind of way you like! Oh, finished! If you have any questions, please contact the author! Liujiayu10@hotmail.com