[英]URI Formats not Supported: while downloading remote file from Web client in c#
I'm trying to download a file from the server . 我正在尝试从服务器下载文件。 While passing a link to the download File , it is throwing an error
在传递下载文件的链接时,它会抛出错误
**URI Formats are not supported ** and pointing at "link "- string contains server file address **不支持URI格式**并指向“链接” - 字符串包含服务器文件地址
string link =
http:\\www.nse-india.com\DERIVATIVES\2012\AUG\fo22AUG2012bhav.csv.zip
WebClient wc = new WebClient();
var ua = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
wc.Headers.Add(HttpRequestHeader.UserAgent, ua);
wc.Headers["Accept"] = "/";
and downloading code goes like this 并下载代码就像这样
try
{
wc.DownloadFile(@link, "H:\\ZipTest\\ZipText\\nt.zip"); // Here Showing error
_status = true;
fileCount++;
} catch (Exception ex)
{
MessageBox.Show(ex.Message);
_status = false;
}
if i used the same address in the web browser it downloading properly or if a replace some other files then also i can download from the same code only for this particular file i am facing problem , any idea?? 如果我在网络浏览器中使用相同的地址,它正确下载或如果更换一些其他文件,那么我也可以从相同的代码下载只为这个特定的文件我面临问题,任何想法?
Your url is corrupted: http:\\www.nse-indi.......
. 你的网址已损坏:
http:\\www.nse-indi.......
It should be something like http://www.nse-india.com/DERIVATIVES/2012/AUG/fo22AUG2012bhav.csv.zip
它应该像
http://www.nse-india.com/DERIVATIVES/2012/AUG/fo22AUG2012bhav.csv.zip
Url need little modification 网址需要很少的修改
Change 更改
string link =
"http:\www.nse-india.com\DERIVATIVES\2012\AUG\fo22AUG2012bhav.csv.zip"
To 至
string link =
"http://www.nse-india.com/DERIVATIVES/2012/AUG/fo22AUG2012bhav.csv.zip"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.