Results 1 to 6 of 6
  1. #1
    shotyoudie's Avatar
    Join Date
    May 2009
    Gender
    female
    Posts
    119
    Reputation
    10
    Thanks
    6
    My Mood
    Angelic

    [Help]Search a file for item

    Hello i want to search config_mp.cfg file from mw2 and find this piece:r_fullscreen "0" and able to save the file again with r_fullscreen "1" i know the part of saving and loading file etc. But how can i search a file for that item?

  2. #2
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    [php]Using sRead as new io.streamreader("path")
    Dim full as string = sRead.ReadToEnd

    full = full.replace("old", "new")
    end using[/php]

    [php]Using sWrite as new io.streamwriter("path")
    sWrite.write(full)
    end using
    [/php]

    [php]If full.contains("bla") then

    end if[/php]



  3. The Following User Says Thank You to Blubb1337 For This Useful Post:

    Qizzle15401 (01-17-2011)

  4. #3
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed
    i coudn't get it what i understood u want to search for a file named with config_mp.cgf
    in mw2 folder and find in it's text r_fullscreen "0" and replace it with r_fullscreen "1" then save it is't right?
    if so
    Dim S As String = Nothing
    Dim Mw2Config_mpcfgLocation As String = Nothing 'replace nothing with the location of config_mp.cfg
    S = My.Computer.FileSystem.ReadAllText(Mw2Config_mpcfg Location)
    S = S.Replace("0", "1")
    System.IO.File.WriteAllText(Mw2Config_mpcfgLocatio n, S)
    this get all text of config_***.cgf to s declared string then it replaces 0 in it with one
    if i'm wrong please tell me what you want
    Last edited by T0P-CENT; 01-17-2011 at 09:41 AM.

  5. The Following User Says Thank You to T0P-CENT For This Useful Post:

    Qizzle15401 (01-17-2011)

  6. #4
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,858
    Reputation
    3438
    Thanks
    101,670
    My Mood
    Breezy
    That just replaces every 0 to 1, you trying to kill someone?

    Replace filePath with the correct file path.

    [php] Dim filePath As String = Nothing
    Dim contents As String = IO.File.ReadAllText(filePath)
    Dim write As String
    Dim RegPattern As New System.Text.RegularExpressions.Regex("r_fullscreen ""[0-9]+""")
    write = RegPattern.Replace(contents.ToString, "r_fullscreen ""0""")
    IO.File.WriteAllText(filePath, write)[/php]
    Last edited by master131; 01-17-2011 at 03:44 PM.
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.7.3
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]

  7. #5
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed
    Quote Originally Posted by master131 View Post
    That just replaces every 0 to 1, you trying to kill someone?
    oh , never thought of that
    Code:
    Dim S As String = Nothing
    Dim Mw2Config_mpcfgLocation As String = Nothing 'replace nothing with the location of config_mp.cfg
    S = My.Computer.FileSystem.ReadAllText(Mw2Config_mpcfg Location)
    S = S.Replace("r_fullscreen ""0""", "r_fullscreen ""1""")
    System.IO.File.WriteAllText(Mw2Config_mpcfgLocatio n, S)
    this should work

  8. #6
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    2 Lines of disgusting code for j00 (could be shortened to one but oh well

    [php]
    Dim loc As String = "C:\Test\Test.txt"
    IO.File.WriteAllText(loc, IO.File.ReadAllText(loc).Replace("r_fullscreen 0", "r_fullscreen 1"))
    [/php]

    Oh yeah.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)