Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am creating a windows applciation where i have DataTable which contains URLS of file i have to download to a local system.. How can i do it..
I used WebClient and its DownnloadFileAsyn but the file is not being downloaded and no error is there . can any one help

[Pasted on behalf of OP]
C++
foreach (DataRow _drDevice in dtDeviceLoogos.Rows)
{
    using (WebClient Client = new WebClient())
    {
        Client.DownloadFile(_drDevice["LogoPath"].ToString(), 
             "D:\\Logos\\_drDevice[""].ToString());
    }
}
Posted
Updated 12-Sep-13 23:04pm
v2
Comments
nv3 13-Sep-13 4:02am    
Without showing your code, chances are not very high that anybody will be able to help you on this.
Arjun Menon U.K 13-Sep-13 4:08am    
foreach (DataRow _drDevice in dtDeviceLoogos.Rows)
{
using (WebClient Client = new WebClient())
{
Client.DownloadFile(_drDevice["LogoPath"].ToString(), "D:\\Logos\\_drDevice[""].ToString());
}
}

The code above causing an error "An exception occurred during a WebClient request."
Richard MacCutchan 13-Sep-13 4:11am    
Then you should catch the exception and print its details. However, looking at your call to the DownLoadFile method, it may well be that your source or target paths are wrong. Use your debugger to see what is happening.
Arjun Menon U.K 13-Sep-13 4:24am    
i created a counter and set the counter name as file with extension , then its saving fine.. but i want to save in the original file format
Prasad Khandekar 13-Sep-13 4:14am    
Have you checked the value of "D:\\Logos\\_drDevice[""].ToString()" It is creating an invalid local path. It should be a valid local file path & name. e.g. ""D:\\Logos\\" + _drDevice[""].ToString() assuming that _drDevice[""].ToString() gives a valid file name.

1 solution

http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx[^]

WebClient* Client = new WebClient();// or do it like in the link.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900