真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net操作ini VBNET有什么用

VB.NET怎么刪除INI文件里的一個字段或鍵值?

1,對于INI文件,可以當(dāng)做像TXT文件一樣來進行讀取和寫入。

創(chuàng)新互聯(lián)公司是一家從事企業(yè)網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、做網(wǎng)站、行業(yè)門戶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計制作的專業(yè)網(wǎng)站設(shè)計公司,擁有經(jīng)驗豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁設(shè)計人員,具備各種規(guī)模與類型網(wǎng)站建設(shè)的實力,在網(wǎng)站建設(shè)領(lǐng)域樹立了自己獨特的設(shè)計風(fēng)格。自公司成立以來曾獨立設(shè)計制作的站點超過千家。

2,先把整個文件度出來,然后找到相應(yīng)行刪除(拋棄)以后,再重新寫入文件。

Public?Class?Form1

Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click

Dim?MyStr?As?String?=?""

Dim?AllStr?As?String?=?""

'獲取一個可用的文件號

Dim?MyFileNum?As?Integer?=?FreeFile()

'打開指定的文件,進行讀取操作

FileOpen(MyFileNum,?"C:\My.ini",?OpenMode.Input)

Do?While?Not?EOF(MyFileNum)

'讀取一行

MyStr?=?LineInput(MyFileNum)

If?MyStr??"b=2"?Then

If?AllStr?=?""?Then

AllStr?=?AllStr??MyStr

Else

AllStr?=?AllStr??vbCrLf??MyStr

End?If

End?If

Loop

FileClose(MyFileNum)???'關(guān)閉文件

'寫文件

Dim?MyStream?As?New?System.IO.FileStream("C:\My.ini",?IO.FileMode.Create)

Dim?MyWriter?As?New?System.IO.StreamWriter(MyStream,?System.Text.Encoding.UTF8)

MyWriter.WriteLine(AllStr)

MyWriter.Flush()

MyWriter.Close()

MyStream.Close()

End?Sub

End?Class

求大神指點 vb.net 怎么讀 ini 配置呢

VB.NET讀寫INI配置文件

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim path As String

path = Application.StartupPath + "\Send.ini"

TextBox1.Text = GetINI("Send", "Send1", "", path)

TextBox2.Text = GetINI("Send", "Send2", "", path)

Dim IsSms As Integer = GetINI("Send", "IsSms", "", path)

If (IsSms = 1) Then

Me.RadioButton1.Checked = True

ElseIf (IsSms = 0) Then

Me.RadioButton2.Checked = True

End If

End Sub

Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String

Dim Str As String = LSet(Str, 256)

GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)

Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)

End Function

Public Function WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long

WriteINI = WritePrivateProfileString(Section, AppName, lpDefault, FileName)

End Function

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try

Dim path As String

path = Application.StartupPath + "\Send.ini"

WriteINI("Send", "Send1", TextBox1.Text, path)

WriteINI("Send", "Send2", TextBox2.Text, path)

If (Me.RadioButton1.Checked = True) Then

WriteINI("Send", "IsSms", 1, path)

ElseIf (Me.RadioButton2.Checked = True) Then

WriteINI("Send", "IsSms", 0, path)

End If

MsgBox("配置設(shè)置已經(jīng)成功!!??!")

Catch ex As Exception

MsgBox("錯誤?。。。?)

End Try

End Sub

vb.net ini操作

名字有規(guī)律,就可以for循環(huán)。

名字沒有規(guī)律,可以想辦法讓他有規(guī)律,一種方法是設(shè)置包含所有節(jié)名稱的string數(shù)組,再循環(huán)。


網(wǎng)站標(biāo)題:vb.net操作ini VBNET有什么用
網(wǎng)址分享:http://weahome.cn/article/hihged.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部