Results 1 to 4 of 4

Thread: Editing a text file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    137

    Editing a text file

    hi all
    i want to edit this in a text file
    <key>homescreen-wallpaper</key>
    <false/>
    to
    <key>homescreen-wallpaper</key>
    <true/>
    it's the 24th line
    thx in advance

  2. #2
    Lively Member
    Join Date
    Jan 2010
    Posts
    124

    Re: Editing a text file

    This is an XML file, right? I think I remember reading somewhere that XML files are not editable. You need to create an entirely new file. But I'm not sure about this, so please correct me if I'm wrong.

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Editing a text file

    you can edit it.
    if you want to post the file i'll write you an example

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Editing a text file

    vb Code:
    1. Dim lines() As String = IO.File.ReadAllLines("filename")
    2. lines(Array.IndexOf(lines, "<key>homescreen-wallpaper</key>") + 1) = lines(Array.IndexOf(lines, "<key>homescreen-wallpaper</key>") + 1).Replace("False", "True")
    3. IO.File.WriteAllLines("filename", lines)

Posting Permissions

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



Click Here to Expand Forum to Full Width