专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > C++ Builder

关于c#解决方案

发布时间:2011-06-28 14:06:07 文章来源:www.iduyao.cn 采编人员:星星草
关于c#
如何上传?


------解决方案--------------------
用FTP你方法多的很,你到msdn搜索一下!
------解决方案--------------------
string url = "www.baidu.com";
Uri uri = new Uri(url);
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.Default, true);
string html = sr.ReadToEnd();
Encoding encoding = sr.CurrentEncoding; //Read() 与 Close() 间读取实际编码
sr.Close();
s.Close();
response.Close();

//保存成文件
StreamWriter sw = new StreamWriter(@"c:\baidu.htm", false, encoding);
sw.Write(html);
sw.Close();
------解决方案--------------------
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//浏览文件
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog MyDlg = new OpenFileDialog();
MyDlg.CheckFileExists = true;
if (MyDlg.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = MyDlg.FileName;
}
}
//上传文件
private void button2_Click(object sender, EventArgs e)
{
string MyFile = this.textBox1.Text;
if (!System.IO.File.Exists(MyFile))
{
MessageBox.Show(MyFile + "文件不存在!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
try
{
Microsoft.VisualBasic.Devices.Computer My =new Microsoft.VisualBasic.Devices.Computer();
My.Network.UploadFile(MyFile, this.textBox2.Text, "", "", true, 500);
MessageBox.Show(MyFile+"文件已经完成上传!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception MyEx)
{
MessageBox.Show(MyEx.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
//关闭程序
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
}
------解决方案--------------------
csdn下载
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: