OpenRead(string uri)
#region 读取指定uri的html
/// <summary>
/// 读取指定uri的html
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, EventArgs e)
{
WebClient wc = new WebClient();
string uri = "http://127.0.0.1/rss/sina.aspx";
Stream stream = wc.OpenRead(uri);
StreamReader sr = new StreamReader(stream);
string strLine = "";
while ((strLine = sr.ReadLine()) != null)
{
this.listBox1.Items.Add(strLine);
}
sr.Close();
}
#endregion
OpenWriter(string uri,string method)
#region 打开一个流使用指定的方法将数据写入到uri
/// <summary>
/// 打开一个流使用指定的方法将数据写入到uri
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
WebClient wc = new WebClient();
string uri = "http://192.168.0.35/cims30/rss.txt";
Stream stream = wc.OpenWrite(uri, "PUT");
StreamWriter sw = new StreamWriter(stream);
sw.WriteLine("HelloWorldHelloWorldHelloWorldHelloWorld");
sw.Flush();
sw.Close();
MessageBox.Show("OK");
}
#endregion
#region 把本地文件上传到指定uri
/// <summary>
/// 把本地文件上传到指定uri
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
WebClient wc = new WebClient();
string targetPath = "http://127.0.0.1/rss/Data Configuration.zip";
string sourcePath = "d:\\Data Configuration.zip";
this.label1.Text = string.Format("uploading {0} to {1}", targetPath, sourcePath);
byte[] bt = wc.UploadFile(targetPath, "PUT", sourcePath);
MessageBox.Show("OK");
}
#endregion
#region 把数据缓冲区上载到指定资源
/// <summary>
/// 把数据缓冲区上载到指定资源
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
WebClient wc = new WebClient();
string targetPath = "http://127.0.0.1/rss/kaifeng.jpg";
string sourcePath = @"C:\test.jpg";
FileStream fs = new FileStream(sourcePath, FileMode.Open, FileAccess.Read);
byte[] bt = new byte[fs.Length];
fs.Read(bt, 0, bt.Length);
wc.UploadData(targetPath, "PUT", bt);
}
#endregion
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有