关于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下载
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
C#项目中如何更改项目保存的文件夹名?
求解。。
------解决方案--------------------
好像需要重构吧,同样求高人解答。
------...
-
C#中让TextBox只能输入数字的问题
我用的如下的代码:
static private Regex r = new Regex("^[0-9]{1,}$ ");
...
-
带数据库的程序打包注意什么?
打的包出错:Error:System.InvalidOperationException: ExecuteReader 要求已打开且可用的连接。连接的...
-
想学习一下网络程序开发 请给推荐几本书
学习基于http协议的程序开发 比如获取网页 分析网页 模拟网页操作 下载上传文档等知识 ...
-
qq的安装包是用什么工具?
想用.net制作一个想qq一样比较漂亮的安装包。有例子最好
------解决方案--------------------
新建->安...
-
C# 写的windows服务 调用 C++ dll 的问题
我封装了一个dll
用一个普通的winform程序 调用的时候没 问题。
但是放在C#写的服务程...
-
在VS2005中怎么调出 解决方案 那个图标?(图示)求解释~~~
这是我用的VS
这是我在教学视频上看到的VS
------解决方案------------...
-
寻友
有人在自学c#编程吗,可以互相认识一下,以后共同探讨学习中的问题……
------解决方案--------------------
朋友多了,路好走~
...
-
急!急!急!C#代码
怎样将数据库中的数据动态加载到Treeview控件中
------解决方案--------------------
C# code
void CreateTree(T...
-
救急??????????????????
哪位高手帮我一下,在C#中怎么写关于鼠标和键盘监听事件,我的程序就差监听鼠标和键盘是否动,然后定时关机这个功能了,请高手指点,...