foreach (string line in PatchLine)
{
try
{
ScanReq HttpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://" + host + "/" + line);
ScanReq.Method = "GET";
ScanReq.UserAgent = "Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.2.15 Version/10.10";
ScanResp HttpWebResponse = (HttpWebResponse)ScanReq.GetResponse();
Console.Write("the Directory IS: (" + line + ") server response: "+ ScanResp.StatusCode + "\n"); // HTTP 200 OK
ScanResp.Close();
}
catch (WebException ScanExcp) // if there is any response from the server 200 also means no directory :)
{
Console.Write("Directory: (" + line + ") NO: "+ ((HttpWebResponse)ScanExcp.Response).StatusCode + "\n");
}
}
Find more questions by tags C#