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

kirkonpolttaja

Senior Member
Joined
Feb 6, 2010
Messages
1,030
Reaction score
674
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();
 
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]
}
 
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).
 
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..)
 
Back
Top