有关下载文件的问题 [英] Question regarding downloading a file
问题描述
朋友们,
大家早上好.
我有一个关于从URL下载文件的问题.我的问题是URL不是我们要下载的文件的直接路径,而是调用了一些返回打开/保存对话框的方法.但是我的要求是,当我单击某个按钮时,我需要将该文件保存到本地磁盘位置.
为此,我使用了webclient,但它正在将html页面下载到Word文档,但我只需要Word文档.
Hi friends,
good morning all..
I have a question on downloading a file from the URL.My question is URL is not the direct path of the file we are going to download rather it calls some method which returns a open/save dialog. but my requirement is while am clicking on some button i need to get that file to local disk location.
To do this i used webclient but it is downloading html page to word document but i need word document only.
private void button1_Click(object sender, EventArgs e)
{
string downloadlink = webbrowser.Document.GetElementById("download").GetAttribute("href");
WebClient client = new WebClient();
client.DownloadFile(downloadlink, @"E:\Suresh_works\test.doc");
}
在downloadlink中获取这样的路径:: http://mydomain.com/view/download?uname=test&sid=123
在复制并粘贴到浏览器中时,它会打开一个对话框,以选择选项open/save/cancel
我想将该文件复制到按钮中的本地磁盘位置,单击
我正在研究Web浏览器控件
....................................
谢谢
SureshV
in downloadlink am getting the path like this :: http://mydomain.com/view/download?uname=test&sid=123
when am copy and paste in browser it opens a dialog to choose the option open/save/cancel
i want that file to copy to my localdisk location in button click
Am working on webbrowser control
...........................
Thanks
SureshV
推荐答案
suresh ...
我认为您的问题是"downloadlink"字符串...
请检查此字符串值是否提供您要下载的文件的正确路径.它应该是文件的完整服务器路径...
thnks ....
达瓦尔·帕特尔(Dhaval Patel)
hi suresh ...
i think ur problem is "downloadlink" string ...
plz check this string value is giving correct path of the file u want to download.. it should be full server path of the file...
thnks....
Dhaval Patel
这篇关于有关下载文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!