これはかなり簡単なことですが、ここで何か見落としていると思います。C#ストリームは最初の行をスキップし続ける
いいえ、私はHttpWebRequestとWebResponseを使ってRobots.txtがサーバー上に存在するかどうかを検出します(それは完璧に機能します)。しかし、私はmyList.Add(reader.ReadLine())を行うために追加しようとしています。どちらが効果的かしかし、問題は、最初の行を飛ばし続けていることです。
https://www.assetstore.unity3d.com/robots.txt <これは私が問題に気付き始めた(ちょうど私が話していることを知っている)。これはテスト目的のためのものです。 (そのリンクを見れば、私が話していることについてのアイデアを得ることができます)。
誰でも、読者を私のリストに追加することはありません(最初の行のみ)。だから私は何が起こっているのか正確に理解していない、私はこれを見てみました、私が意図して行を飛ばしたいと思っている唯一のものは、私はそれをしたくありません。
マイコード以下。
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();
読み取りラインを呼び出すの変更;' - 'do' /'にあなたの 'while'を変更while'。 – Enigmativity
今すぐお試しください。 – n1warhead
ありがとうございました。 – n1warhead