Array + edit + save

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beyrself
    New Member
    • Dec 2008
    • 6

    Array + edit + save

    Hi,all

    What i am trying to do now is to show the content of the dnsredir.ini file on the forms and able to edit it.

    The dnsredir.ini file file looks like this

    Code:
     
    ;Configuration INI file for DNS Redirector v6.4.7
     
    Logging=Normal
     
    ListenOnIP=172.23.128.33
     
    DNSServerIP=172.122.16.98
     
    SimpleDNS=
     
    RedirectIP=
    AuthKeywordsFile=
    AlwaysKeywordsFile=always.txt
    AuthClientsFile=
     
    BlockedIP=172.26.128.33
    BlockedKeywordsFile=blocked.txt
    AllowedKeywordsFile=allowed.txt
    BypassBlockFile=bypassblock.txt
     
    RestrictIP=
    RestrictStart=
    RestrictEnd=
    BypassRestrictFile=
     
    ActionNumber=0
    JoinType=Detect
    JoinAction=
    LeaveAction=
     
    ClientTimeout=20
     
    MinToTray=False
    CloseToTray=False
     
    ;Save this INI then close and restart dnsredir.exe so changes become active

    I need to be able to read the file and edit it line by line.. for example

    ListenOnIP=172. 26.128.33 is on line 5.
    I need to be able to edit 172.26.128.33 on line 5
    and when i click save it will be save on the same line in the .INI file.

    I think i need to use array or something but I am very new to Vb. I seriously need help! Please Help with the coding. Thanks!
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    Typically INI files have [sections], did you remove them? Does the program that reads the INI file require that certain text be on specific lines or do you just want the text to remain on the original line for your own reasons?

    Since you're new to VB, are you using Visual basic (4, 5, or 6) or are you using VB.Net (2003/2005/2008) which belongs in the VB.Net section?

    Going off your post you would look for an example of reading the full text into a string. Then you can split it into an array delimited by vbcrlf and then re-write the original with the new information.

    If the ini followed typical INI structure and had sections then you should be able to use just about any INI editing examples if you didn't care to keep the original key name/value pairs on the same line.

    Comment

    Working...