社区
C#
帖子详情
WinForm会的进来看看
namcer8816
2012-07-24 09:01:15
我想实现 winfrom窗体中 button事件 实现,当点击时候下载制定文件路径的zip 文件。 帮帮忙 新手啊
!!
...全文
177
7
打赏
收藏
WinForm会的进来看看
我想实现 winfrom窗体中 button事件 实现,当点击时候下载制定文件路径的zip 文件。 帮帮忙 新手啊 !!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
hlqnlbsn627
2012-07-24
打赏
举报
回复
楼猪加油,我也在想这个问题
lenovore
2012-07-24
打赏
举报
回复
using System.Net;
using System.IO;
/// <summary>
/// 下载服务器至客户端
/// </summary>
/// <param name="URL">被下载的地址, 绝对路径</param>
/// <param name="Dir">另存放的目录</param>
public static void Download(string URL, string Dir)
{
WebClient client = new WebClient();
string fileName = URL.Substring(URL.LastIndexOf("/") + 1); //被下载的名
string Path = Dir + fileName; //另存为的绝对路径+名
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "GET";
//request.Timeout = 300000;
request.KeepAlive = true;
request.AllowAutoRedirect = true;
request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET CLR 2.0.50727; CIBA)";
request.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse webresponse = null;
try
{
webresponse = request.GetResponse() as HttpWebResponse;
if (webresponse != null)
{
Stream st = webresponse.GetResponseStream();
Stream so = new FileStream(Path, FileMode.Create);
byte[] by = new byte[1024];
int osize = st.Read(by, 0, (int)by.Length);
while (osize > 0)
{
so.Write(by, 0, osize);
osize = st.Read(by, 0, (int)by.Length);
}
so.Close();
st.Close();
}
}
catch (System.Exception e)
{
}
finally
{
if (webresponse != null)
{
webresponse.Close();
webresponse = null;
}
if (request != null)
{
request.Abort();
request = null;
}
}
}
sjms_xf1
2012-07-24
打赏
举报
回复
这个问题不难,对不起是在没时间写这个,友情帮顶了,免得你沉贴
shizhusz110
2012-07-24
打赏
举报
回复
一楼正确+
SocketUpEx
2012-07-24
打赏
举报
回复
不行就不行了
[Quote=引用 2 楼 的回复:]
引用 1 楼 的回复:
using System;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
WebClient webClient = new WebClient();
webClient.DownloadFil……
[/Quote]
namcer8816
2012-07-24
打赏
举报
回复
[Quote=引用 1 楼 的回复:]
using System;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
WebClient webClient = new WebClient();
webClient.DownloadFile(u……
[/Quote]
不行啊!
SocketUpEx
2012-07-24
打赏
举报
回复
using System;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
WebClient webClient = new WebClient();
webClient.DownloadFile(url, path);
Console.ReadKey();
}
}
}
winform
内嵌unity
都是为了学习,转载时不用打招呼,标明出处就行,实在不想标明,也可以!
WinForm
(一)
WinForm
入门与基本控件使用
2.窗口设计与控件布局 3.窗口事件 (1)界面设计(2)逻辑代码 二.
WinForm
布局开发 3.逻辑事件代码Form.cs 四.图片框与项目资源 1.添加资源
WinForm
学习
C#学习
winform
事件:现实中要做的或者已发生事情。用户和windows与控件交互的“桥梁”,用来响应用户的各种操作 (点击事件,用户输入文本框等)1. 事件的3要素 事件的目标 事件属性 事件执行程序事件的目标 :交互的控件对象事件属性:事件目标和用户交互的不同状态事件执行程序:事件目标和用户时执行的结果2、事件绑定方式1.控件绑定法:找到对应控件事件属性 填入对应事件执行程序名称 在事件执行程序中完成对应逻辑2.自定义事件方法和绑定事件方法(用于代码法创建控件时使用)
C#
WinForm
常用的开源控件
记录C#
WinForm
常用的开源控件集1、Circular ProgressBar for
WinForm
2、Live Charts 1、Circular ProgressBar for
WinForm
Github地址:https://github.com/falahati/CircularProgressBar 2、Live Charts Github地址:https://github.c...
C#
111,129
社区成员
642,531
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章