System.Net.WebClient.DownloadFile(Uri address, String fileName)

namespace:System.Net

参数:

address:The URI from which to download data.
fileName:The name of the local file that is to receive the data.

eg:

 /// <summary>
/// 保存文件到本地
/// </summary>
/// <param name="filePath">uri</param>
/// <param name="folderPath">localDir</param>
/// <param name="localFilePath">folderPath+fileName</param>
public void SaveDownFile(string filePath, string folderPath, string localFilePath)
{
try
{
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
WebClient DownFile = new WebClient();
DownFile.DownloadFile(filePath, localFilePath);
logger.WriteSystemLog(LogLevel.Const, "successfully saveDownFile:" + localFilePath);
}
catch (Exception ex)
{
logger.WriteExceptionLog(ex, " saveDownFile Exception: httpUrl=" + filePath);
}
}
 public static long userId = ;
public static string userCode;
public static string token;
public static string clientIP;
// 单点登录
protected void sso()
{
clientIP = GetClientIP();// local IP
userId = GetUserId();
userCode = GetUserCode();
token = sendMessage(userId, userCode, clientIP);// 发送验证消息 if (!string.IsNullOrEmpty(token))
{
delayTime();
simLogin(token);
}
} // 登录
private void simLogin(string token)
{
var url = string.Format("http://192.168.12.250:8900/Login?userId={0}&clientIP={1}&token={2}", userCode, clientIP, token);
WebClient wc = new WebClient();
byte[] ret = wc.DownloadData(url);
} private void delayTime(double secend)
{
DateTime tempTime = DateTime.Now;
while (tempTime.AddSeconds(secend).CompareTo(DateTime.Now) > )
System.Windows.Forms.Application.DoEvents();
}

C#WebClient常见用法的更多相关文章

  1. Linux中find常见用法

    Linux中find常见用法示例 ·find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \; find命令的参数 ...

  2. php中的curl使用入门教程和常见用法实例

    摘要: [目录] php中的curl使用入门教程和常见用法实例 一.curl的优势 二.curl的简单使用步骤 三.错误处理 四.获取curl请求的具体信息 五.使用curl发送post请求 六.文件 ...

  3. Guava中Predicate的常见用法

    Guava中Predicate的常见用法 1.  Predicate基本用法 guava提供了许多利用Functions和Predicates来操作Collections的工具,一般在 Iterabl ...

  4. find常见用法

    Linux中find常见用法示例 ·find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \; find命令的参数 ...

  5. iOS 开发多线程篇—GCD的常见用法

    iOS开发多线程篇—GCD的常见用法 一.延迟执行 1.介绍 iOS常见的延时执行有2种方式 (1)调用NSObject的方法 [self performSelector:@selector(run) ...

  6. iOS开发多线程篇—GCD的常见用法

    iOS开发多线程篇—GCD的常见用法 一.延迟执行 1.介绍 iOS常见的延时执行有2种方式 (1)调用NSObject的方法 [self performSelector:@selector(run) ...

  7. [转]EasyUI——常见用法总结

    原文链接: EasyUI——常见用法总结 1. 使用 data-options 来初始化属性. data-options是jQuery Easyui 最近两个版本才加上的一个特殊属性.通过这个属性,我 ...

  8. NSString常见用法总结

    //====================NSStirng 的常见用法==================== -(void)testString { //创建格式化字符串:占位符(由一个%加一个字 ...

  9. [转]Linux中find常见用法示例

    Linux中find常见用法示例[转]·find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \;find命令的参 ...

随机推荐

  1. IOS5中的Safari不兼容Javascript中的Date问题

    在IOS5以上版本(不包含IOS5)中的Safari浏览器能正确解释出Javascript中的 new Date('2016-06-07') 的日期对象. 但是在IOS5版本里面的Safari解释ne ...

  2. 知识积累:DAS NAS SAN

    DAS(Direct Acess Storage—直接连接存储)是指将存储设备通过SCSI接口或光纤通道直接连接到一台计算机上.NAS(Network Attached Storage)—网络连接存储 ...

  3. yII中利用urlManager将URL改写成restful风格 这里主要涉及url显示样式

    1.打开config文件夹下面的mian.php   2.修改内容   如把地址http://www.test.com/index.php?r=site/page/sid/1修改为http://www ...

  4. 安装thrift全过程

    为了研究基于thrift的RPC框架,其实,是想自己基于thrift写一个微服务的platform.首先就是安装Thrift,便于IDL架构生成java的接口文件.多的不说了,开始install的过程 ...

  5. 无线路由器WDS简要

    A,B两台无线路由器,B去桥接A.在B中保持A相同的无线信道.在B中关闭DHCP.--A,B两台的SSID和无线安全设置都是独立的,无线安全可同可不同.

  6. 1 、Linux-Rhel6终端介绍-Shell提示符

    1.Linux 终端介绍 tty-控制台终端: RHEL6 tty1-tty6  tty就是图形界面 从图形界面切换到字符界面: ctrl+shift+alt +F2~F6 从字符界面切换图形或字符: ...

  7. oracle10g在rh6上安装缺少libXtst*的包导致不能出OUI

    由于测试需要,今天在linux6.0上装了下oracle10g,确实是知道oracle10g已经不支持redhat5.0以后的版本了,但是根据自己以往在redhat5.0上装oracle的经验就鲁莽下 ...

  8. zen coding和emmet

    zen coding 改名为 emmet http://emmet.io/download/

  9. (LinkedList)2. Add Two Numbers

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  10. ReSharper 文件注释

    添加文件注释方法如下: 打开菜单RESHARPER->Options->Code Editing –> File Header Text 如图所示,在其中空白处添加对应文件头注释, ...