I'm creating a quick project which takes a .txt from the user, saves each line to an array and then makes a request for each ID, depending if the response contains 'The profile could not be found', or a valid profile, act accordingly.
Here's my code;
static void Main(string[] args)
{
string[] lines = System.IO.File.ReadAllLines(@"C:\\users\\louis\\Desktop\\d.txt");
string[] avaliableIds = { };
string errorMessage = "The specified profile could not be found.</h3><br><br>";
foreach (string c in lines)
{
WebRequest req = WebRequest.Create("http://steamcommunity.com/id/" + c);
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
string returne = sr.ReadToEnd();
System.Threading.Thread.Sleep(100);
if (returne.Contains(errorMessage))
{
int avaliableArrayLength = avaliableIds.Length;
int shouldGo = avaliableArrayLength + 1;
avaliableIds[shouldGo] = c;
} // Here is where I'm getting the error
}
for(int i = 0; i == avaliableIds.Length; i++)
{
Console.WriteLine(avaliableIds[i]);
}
}
From what I understand, 'shouldGo' has a higher value than 'avaliableIds', so something is wrong with my declaration, it's supposed to be an array which can hold as high as or as low any number possible.
Please help, thanks.