1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[c#] Text rotation? (names, emails, proxies)

Discussion in 'C, C++, C#' started by kirkonpolttaja, May 30, 2012.

  1. kirkonpolttaja

    kirkonpolttaja Senior Member

    Joined:
    Feb 6, 2010
    Messages:
    1,027
    Likes Received:
    670
    I'm making a simple bot but i'm little stuck here... how can i pick string from single row from .txt file to be used (application function examples: proxy rotation, emails, or other registration info).

    Also extra function that i need is that it will go row-by-row or randomize row selection.

    for randomized i'v used this:

    Code:
    string[] lines = File.ReadAllLines("proxies.txt");
    Random rand = new Random();
    string prox = lines[rand.Next(lines.Length)];
    then ably string called prox for webbrowser proxy function (it works if i look at "what my ip"-google).

    How can i make it so that the software goes every proxy one by one? (row by row).

    somekind of iteration until "(last line == null);" and then message me "DONE!" + break();
     
  2. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,062
    You want to loop through every single proxy that's stored in the text file?

    Code:
    for(int i = 0; i < lines.Length; ++i)
    {
        //do something with lines[i]
    }
     
  3. kirkonpolttaja

    kirkonpolttaja Senior Member

    Joined:
    Feb 6, 2010
    Messages:
    1,027
    Likes Received:
    670
    yeah i need to go through all of them, but then randomizing proxies is nonsense as the app should go through all proxies periodically line by line.

    I will shoot you a PM if you have time to help me out a little to figure out what should be done with my so far done code (it's short dontcha worry).
     
  4. haylander

    haylander Registered Member

    Joined:
    May 24, 2009
    Messages:
    54
    Likes Received:
    20
    if you use the class random,The variable has to be static to produce "random" numbers.

    A better approach of randomzing file lines(using Linq)

    Code:
    Try
    {
                    List<string>usernames = File.ReadAllLines("profile/usernames.txt").OrderBy(a => Guid.NewGuid()).ToList<string>();
    }
    catch (for file not found/access permission etc..)