dcsimg
Results 1 to 5 of 5

Thread: How to read ini file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    12

    How to read ini file

    Hi, in my project, i want to read an ini file - i.e. C:\xyz.ini

    ini contains:

    Code:
    [0089]
    Vendor=INTEL
    8874=28F640W18TE
    8981=NU48F256
    8982=NU48F512
    I can read through usb - i.e. phone id : "89820089"
    Now 8982 should = to NU48F512 as we have it in ini.

    Thank you for your help. I don't know what code to read ini from C:\ or whatever.

    BR

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: How to read ini file

    This is very easy to do using application settings via the app.config file. Take a look at this post
    http://www.vbforums.com/showthread.p...&highlight=ini
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  3. #3
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: How to read ini file

    Here is an old article that is still worth reading.

    http://www.devx.com/dotnet/Article/7008
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    12

    Re: How to read ini file

    Quote Originally Posted by wild_bill View Post
    This is very easy to do using application settings via the app.config file. Take a look at this post
    http://www.vbforums.com/showthread.p...&highlight=ini
    Hi, thanks for your reply. I have tried that but does NOT seem to be working.. I read some info from phone and it reads ID: "89820089" I want it to read like that "89820089 = NU48F512 " that NU48xxx will be read out from ini file that will be in 'Project' folder.

    BR and thanks again.

  5. #5
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: How to read ini file

    I used this in my app.config
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
          <section name="PhoneLookup" type="System.Configuration.NameValueSectionHandler"/>
        </configSections>
      <PhoneLookup>
        <add key="89820089" value="NU48F512" />
      </PhoneLookup>
    </configuration>
    To access the data, I used this code:
    Code:
            Dim phoneLookup = CType(System.Configuration.ConfigurationManager.GetSection("PhoneLookup"), System.Collections.Specialized.NameValueCollection)
            Dim myValue = phoneLookup("89820089")
            Debug.WriteLine(myValue)
    You'll have to reference System.Configuration before building.
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width