private void GetConnection() { var setting = new HttpWebDefaultSetting { ChromeId = Global.TraderId }; var connection = Connection.SiteConnection(setting); if (!connection) { startButton.Visible = false; FormHelper.FormSetText("Cannot connect to source"); } }
public static bool SiteConnection(HttpWebDefaultSetting input) { input.Uri = @"https://sites.google.com/site/louiegor/"; string text; var httpRequest = (HttpWebRequest)WebRequest.Create(input.Uri); var response = (HttpWebResponse)httpRequest.GetResponse(); var receiveStream = response.GetResponseStream(); using (var reader = new StreamReader(receiveStream, Encoding.UTF8)) { text = reader.ReadToEnd(); } int first = text.IndexOf("@A@", StringComparison.Ordinal) + "@B@".Length; int last = text.LastIndexOf("@B@", StringComparison.Ordinal); string title = text.Substring(first, last - first); if (title != "louiegor") { return(false); } return(true); }