本文整理汇总了C#中System.IO.StreamReader.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.Remove方法的具体用法?C# StreamReader.Remove怎么用?C# StreamReader.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.Remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BackgroundWorkerDoWork
private void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
{
var url = string.Format("http://www.youtube.com/watch?v={0}", e.Argument);
_errorMessage = string.Empty;
var request = (HttpWebRequest)WebRequest.Create(url);
var response = (HttpWebResponse)request.GetResponse();
var responseStream = response.GetResponseStream();
if (responseStream == null)
{
_errorMessage = "Error while reading response from YouTube.";
return;
}
var source = new StreamReader(responseStream, Encoding.UTF8).ReadToEnd();
var found = source.IndexOf("x-flv");
while (!source.Substring(found, 4).Equals("http"))
found--;
source = source.Remove(0, found);
source = HttpUtility.UrlDecode(source);
source = HttpUtility.UrlDecode(source); //Twice
_errorMessage = source.Substring(0,source.IndexOf("&quality"));
}
示例2: getXS1ActuatorList
public XS1ActuatorList getXS1ActuatorList(String XS1_URL, String Username, String Password)
{
// TODO: more error handling !!!
// check if we already cached something
if (ActuatorListCache != null)
{
if ((DateTime.Now - LastActuatorListUpdated).TotalMinutes < ConfigurationCacheMinutes)
return ActuatorListCache;
}
// now we got the parameters, we need to find out which actors and which functions shall be called
WebRequest wrGetURL = WebRequest.Create("http://" + XS1_URL + "/control?user=" + Username + "&pwd=" + Password + "&callback=actorlist&cmd=get_list_actuators");
String _UsernameAndPassword = Username + ":" + Password;
String _AuthorizationHeader = "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(_UsernameAndPassword));
wrGetURL.Credentials = new NetworkCredential(Username, Password);
wrGetURL.Headers.Add("Authorization", _AuthorizationHeader);
HttpWebResponse response = (HttpWebResponse)wrGetURL.GetResponse();
// check for eventual errors
if (response.StatusCode != HttpStatusCode.OK)
{
// TODO: refactor to correct http response codes
return null;
}
// we will read data via the response stream
String actuator_config_json = new StreamReader(response.GetResponseStream()).ReadToEnd();
JavaScriptSerializer ser = new JavaScriptSerializer();
ser.MaxJsonLength = 20000000;
// remove the javascript callback/definitions
actuator_config_json = actuator_config_json.Replace("actorlist(", "");
actuator_config_json = actuator_config_json.Remove(actuator_config_json.Length - 4, 4);
// deserialize the XS1 configuration json stream
ActuatorListCache = ser.Deserialize<XS1ActuatorList>(actuator_config_json);
LastActuatorListUpdated = DateTime.Now;
return ActuatorListCache;
}
示例3: SetStateActuatorPreset
public String SetStateActuatorPreset(String XS1_URL, String Username, String Password, Int32 ActuatorID, Int32 PresetID)
{
// TODO: more error handling !!!
WebRequest wrGetURL = WebRequest.Create("http://" + XS1_URL + "/control?user=" + Username + "&pwd=" + Password + "&callback=setstate&cmd=set_state_actuator&number="+ActuatorID+"&function="+PresetID);
String _UsernameAndPassword = Username + ":" + Password;
String _AuthorizationHeader = "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(_UsernameAndPassword));
wrGetURL.Credentials = new NetworkCredential(Username, Password);
wrGetURL.Headers.Add("Authorization", _AuthorizationHeader);
HttpWebResponse response = (HttpWebResponse)wrGetURL.GetResponse();
// check for eventual errors
if (response.StatusCode != HttpStatusCode.OK)
{
// TODO: refactor to correct http response codes
return null;
}
// we will read data via the response stream
String actuator_config_json = new StreamReader(response.GetResponseStream()).ReadToEnd();
JavaScriptSerializer ser = new JavaScriptSerializer();
ser.MaxJsonLength = 20000000;
// remove the javascript callback/definitions
actuator_config_json = actuator_config_json.Replace("setstate(", "");
actuator_config_json = actuator_config_json.Remove(actuator_config_json.Length - 4, 4);
return "";
}