alright I'm doing something that should be rather simple, I believe I am overlooking something here.
Alright I and using a HttpWebRequest and a WebResponse to detect if a Robots.txt exists on a server (and that works perfectly fine). However, I am trying to add to do myList.Add(reader.ReadLine()); Which (works). But problem is, it keeps skipping the very first line.
https://www.assetstore.unity3d.com/robots.txt < That is the one I started noticing the problem on (just so you know what I'm talking about). It is just for testing purposes. (Look at that link so you can get an idea as to what I'm talking about).
Anywho, it is also not adding the reader.ReadLine to my list either (first line only). So I'm not exactly understanding what's going on, I've tried looking this up and the only things I'm finding is to purposely want to skip a line, I don't want to do that.
My Code Below.
Console.WriteLine("Robots.txt Found: Presenting Rules in (Robot Rules).");
HttpWebRequest getResults = (HttpWebRequest)WebRequest.Create(ur + "robots.txt");
WebResponse getResponse = getResults.GetResponse();
using (StreamReader reader = new StreamReader(getResponse.GetResponseStream())) {
string line = reader.ReadLine();
while(line != null && line != "#") {
line = reader.ReadLine();
rslList.Add(line);
results.Text = results.Text + line + Environment.NewLine; // At first I thought it might have been this (nope).
}
// This didn't work either (figured perhaps maybe it was skipping because I had to many things.
// So I just put into a for loop, - nope still skips first line.
// for(int i = 0; i < rslList.Count; i++) {
// results.Text = results.Text + rslList[i] + Environment.NewLine;
// }
}
// Close the connection sense it is no longer needed.
getResponse.Close();
// Now check for user-rights.
CheckUserRights();
Change when next you call the read line
var line = reader.ReadLine(); //Read first line
while(line != null && line != "#") { //while line condition satisfied
//perform your desired actions
rslList.Add(line);
results.Text = results.Text + line + Environment.NewLine;
line = reader.ReadLine(); //read the next line
}