How do i read and write ini file using vb.net?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TBoon

    #1

    How do i read and write ini file using vb.net?

    How do i read and write ini file using vb.net?


  • Herfried K. Wagner [MVP]

    #2
    Re: How do i read and write ini file using vb.net?

    "TBoon" <allblacks15@ho tmail.comschrie b:
    How do i read and write ini file using vb.net?
    Storing and loading user preferences
    <URL:http://dotnet.mvps.org/dotnet/faqs/?id=userprefere nces&lang=en>

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    • vbnetdev

      #3
      Re: How do i read and write ini file using vb.net?

      xml is a better way to go in my humble opinion.



      "TBoon" <allblacks15@ho tmail.comwrote in message
      news:OKbPIJSJHH A.3552@TK2MSFTN GP03.phx.gbl...
      How do i read and write ini file using vb.net?
      >

      Comment

      • Jeff Jarrell

        #4
        Re: How do i read and write ini file using vb.net?

        If you are looking for the legacy approach... (pinvoke.net is a nice site
        for finding these sorts of things).

        Class Util
        Public Shared Function readINI(ByVal sSection As String, ByVal sKey As
        String, ByVal sFile As String) As String
        Dim sb As StringBuilder
        Dim iRet As Integer

        sb = New StringBuilder(5 00)

        iRet = WinApi.GetPriva teProfileString (sSection, sKey, "", sb,
        sb.Capacity, sFile)

        Return sb.ToString
        End Function

        Public Shared Sub writeINI(ByVal sSection As String, ByVal sKey As String,
        ByVal sFile As String, ByVal sValue As String)
        Dim bOk As Boolean

        bOk = WinApi.WritePri vateProfileStri ng(sSection, sKey, sValue, sFile)
        End Sub
        end class




        Class WinApi
        <DllImport("ker nel32.dll", SetLastError:=T rue)_
        Public Shared Function GetPrivateProfi leString(ByVal lpAppName As String,
        _
        ByVal lpKeyName As String, _
        ByVal lpDefault As String, _
        ByVal lpReturnedStrin g As StringBuilder, _
        ByVal nSize As Integer, _
        ByVal lpFileName As String) As Integer
        End Function

        <DllImport("ker nel32.dll", SetLastError:=T rue)_
        Public Shared Function WritePrivatePro fileString(ByVa l lpAppName As
        String, _
        ByVal lpKeyName As String, _
        ByVal lpString As String, _
        ByVal lpFileName As String) As Boolean
        End Function
        End Class


        "TBoon" <allblacks15@ho tmail.comwrote in message
        news:OKbPIJSJHH A.3552@TK2MSFTN GP03.phx.gbl...
        How do i read and write ini file using vb.net?
        >

        Comment

        Working...