public static Stream GetStreamFromURL(string strRequest) { Stream responseStream = null; try { if (!String.IsNullOrEmpty(strRequest)) { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strRequest); myRequest.Method = "GET"; myRequest.Timeout = 30000; myRequest.KeepAlive = false; #if USE_ASYNC HttpWebResponse myResponse = (HttpWebResponse)(await myRequest.GetResponseAsync()); #else HttpWebResponse myResponse = (HttpWebResponse)(myRequest.GetResponse()); #endif responseStream = myResponse.GetResponseStream(); //myResponse.Close(); } } catch (Exception ex) { ConsoleMe.WriteLine(ex.ToString()); } return(responseStream); }
public static string ReadLine() { string input = Console.ReadLine(); ConsoleMe.WriteLine(string.Format("{0}, user input: '{1}'.", DateTime.Now.ToLongTimeString(), input)); return(input); }