C# WebClient上传下载资料问题求助
来源:互联网 发布:开源电商系统 php 编辑:程序博客网 时间:2024/05/01 14:10
各位大哥大姐,菜鸟 现求助问题:如下是一段从服务器如\\111.111.111.xx下载一个文件,但是现在发现,下载登录服务器失败,提示信息:“未知的用户名与密码“。手动登录到\\111.111.111.11下载则是没有问题,所以应该是我登录到服务器的有问题,请教各位大侠,如何根据用户名和密码登录到这个\\111.111.111.11服务器上。很急,谢谢帮忙。
//Download file
public static bool DownloadFile(string urlString,string fileName,string fielPath)
{
//<summary>
//下载服务器文件至客户端
//</summary>
//<param name="URL">被下载的文件地址,绝对路径</param>
//<param name="fielPath">绝对路径</param>
string URL = null;
if (urlString.EndsWith(@"\") == false)
{
URL = urlString + @"\";
}
URL = URL + fileName;
WebRequest myre = WebRequest.Create(URL);
WebClient myWebClient = new WebClient();
myWebClient.UseDefaultCredentials = true;
myWebClient.Credentials = new NetworkCredential("Admini", "1111");
//string fileName = URL.Substring(URL.LastIndexOf("\\") + 1); //被下载的文件名
try
{
myWebClient.DownloadFile(URL, fielPath);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
return true;
//Download file
public static bool DownloadFile(string urlString,string fileName,string fielPath)
{
//<summary>
//下载服务器文件至客户端
//</summary>
//<param name="URL">被下载的文件地址,绝对路径</param>
//<param name="fielPath">绝对路径</param>
string URL = null;
if (urlString.EndsWith(@"\") == false)
{
URL = urlString + @"\";
}
URL = URL + fileName;
WebRequest myre = WebRequest.Create(URL);
WebClient myWebClient = new WebClient();
myWebClient.UseDefaultCredentials = true;
myWebClient.Credentials = new NetworkCredential("Admini", "1111");
//string fileName = URL.Substring(URL.LastIndexOf("\\") + 1); //被下载的文件名
try
{
myWebClient.DownloadFile(URL, fielPath);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
return true;
0 0
- C# WebClient上传下载资料问题求助
- C# WebClient上传下载时进度条显示
- C# WebClient上传下载时进度条显示
- 【基础】C# WebClient 上传下载/获取网站源代码
- C# WebClient上传下载时进度条显示
- JSP上传下载文件问题,求助!
- C# WinForm通过WebClient实现文件上传下载 (附源码)
- C# WinForm通过WebClient实现文件上传下载 (附源码)
- webclient、ftpclient上传下载
- C# WinForm通过WebClient实现文件上传下载 (附源码) 分类: C#.NET
- 上传下载资料
- C#用WebClient下载File时操作超时的问题
- C#用WebClient下载File时操作超时的问题
- 求助:C#编程中遇到的问题
- C#问题 设计一个表决器 求助!!!
- C#下载文件:WebClient
- C# WebClient gzip
- c# webclient下载网页
- 菜花1
- 第五章 第一印象
- sql2000利用查询命令进行数据比对
- 晶体管放大电路之负载应用
- 自动创建分区
- C# WebClient上传下载资料问题求助
- 菜花2
- 第六章 女人不世俗
- CUDA5.5入门文章:VS10设置
- 利用Spring 和DBCP实现分布式动态数据库连接池管理
- 远程连接到使用wifi的win7
- 菜花3
- 4A.Watermelon
- summary of android tutorials