Web.Config的读写问题
用下面的方法可以将Web.Config读入到DataSet中,使用DataSet的WriteXML可以将DataSet中读入的Web.Config信息一次写回去,只是以前的注释信息全部丢失了,我现在想问题一个问题,就是能否在Web.config中修改了某一段后,只保存那一段?
Dim ds As DataSet = New DataSet()
ds.ReadXml("C:\inetpub\wwwroot\apptest\web.config")
dg1.DataSource = ds.Tables 'bind all tables in dataset to datagrid
'dg1.DataSource = ds.Tables("add").DefaultView 'bind table "add" to dg
dg1.DataBind()
Dim i As Integer
For i = 0 To ds.Tables("add").Rows.Count - 1 'get the key ConnPM
If ds.Tables("add").Rows(i).Item("key").ToString.Trim = "ConnPM" Then
lbl3.Text = ds.Tables("add").Rows(i).Item("value").ToString.Trim
End If
Next