ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!

Jump to content



Photo

C# Application help (Reading lines from txt files and importing them to the app)


  • Please log in to reply
C# Application help (Reading lines from txt files and importing them to the app)

#1

J5ck
J5ck
    Offline
    13
    Rep
    70
    Likes

    Epic Gamer

  • PipPipPipPipPip
Posts: 204
Threads: 50
Joined: Jan 07, 2019
Credits: 0

Five years registered
#1

Hello, I am currently in the process of making a bot that signs up for instagram.com and follows the users specified account name.

 

 

 

But, I need the application to connect to proxies that the user has given them.

So what I mean is, the user loads a proxies.txt file and now I need the application to read the first line of the proxies.txt file and use the proxy

Then use the second line, third line and so on.

 

Sorry if you don't understand what I mean or this is stupid af :(

 

Thanks for reading.

 

 


  • -1

#2

sunjester
sunjester
    Offline
    2
    Rep
    26
    Likes

    Underwurld Admin

  • PipPipPipPip
Posts: 104
Threads: 90
Joined: Dec 27, 2018
Credits: 0
Five years registered
#2

you just need to read it into an array and loop the array.

string[] proxy_list = File.ReadLines("proxies.txt").ToArray();

so let's hope the proxies.txt isn't huge or you would probably need an ienumerable


Edited by sunjester, 11 March 2019 - 09:16 PM.

  • 0

#3

Nippler
Nippler
    Offline
    -2
    Rep
    11
    Likes

    Advanced Member

  • PipPipPipPip
Posts: 88
Threads: 1
Joined: Jun 28, 2018
Credits: 0
Five years registered
#3

Why coding when there's bunch of python scripts that will prob work better then your shitty c# app.. look for InstaPy on github.


  • -2

#4

J5ck
J5ck
    Offline
    13
    Rep
    70
    Likes

    Epic Gamer

  • PipPipPipPipPip
Posts: 204
Threads: 50
Joined: Jan 07, 2019
Credits: 0

Five years registered
#4

Why coding when there's bunch of python scripts that will prob work better then your shitty c# app.. look for InstaPy on github.

Because I like to learn.

I don't want to leech other peoples work :)


you just need to read it into an array and loop the array.

string[] proxy_list = File.ReadLines("proxies.txt").ToArray();

so let's hope the proxies.txt isn't huge or you would probably need an ienumerable

Thank you very much :-)


  • 0

#5

Psy
Psy
    Offline
    62
    Rep
    355
    Likes

    Godtier

  • PipPipPipPipPipPipPip
Posts: 768
Threads: 44
Joined: Jan 30, 2015
Credits: 0

Deal with caution
User has an open scam report.
Eight years registered
#5

Because I like to learn.

I don't want to leech other peoples work :)


Thank you very much :-)

 

String arrays are fine, but Lists are better in my opinion, just to use out of habit. If you want to load proxies AND use them in a web request you would do so like this:

//Create a string list and store all lines as list item. Lists expand dynamically.
List<string> proxies = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "proxies.txt");

//If you want to iterate through any form of array you use for or foreach. In this situation either would work fine. For example:
for (int i = 0; i < proxies.Count; i++)
{
    //This just outputs the index of value equal to i which is 0,1,2,3,etc every loop
    Console.WriteLine(proxies[i]);
}
//Or you can use foreach
foreach (string proxy in proxies)
{
    Console.WriteLine(proxy);
}

//If you want to make a webrequest with a proxy you can use any request function you prefer, I use WebClient:
//Obviously you'll need to wrap it in a for/foreach loop to iterate through proxies
foreach (string proxy in proxies)
{
    Webclient wc = new WebClient();
    WebProxy myProxy = new WebProxy(proxy)
    wc.Proxy = myProxy;
}

  • 1

Add on discord: Psy#0001




There are impersonators! Psy#5792 and Psy#8130



 Users browsing this thread: