System.Net.WebClient.DownloadFile doesn't work with http attachments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jinsonsanik
    New Member
    • May 2014
    • 1

    System.Net.WebClient.DownloadFile doesn't work with http attachments

    Code:
    Dim A_URL As String = "http://reportserver.com:7403/xmlpserver/Guest/LB_DEV/RMS/Orders/ord_det/ord_det.xdo?_xpf=&_xpt=0&_xdo=%2FGuest%2FLB_DEV%2FRMS%2FOrders%2Ford_det%2Ford_det.xdo&_xmode=4&xdo%3Axdo%3A_paramsPM_order_no_div_input=500036&_paramsPM_order_no=500036&_xt=Purchase%20Order%20Report&_xf=pdf&_xautorun=false"
                Dim B_SAVEAS As String = "C:\reports\xdo.pdf"
    
    
    
                Dim _WebClient As New System.Net.WebClient()
                ' Downloads the resource with the specified URI to a local file.
                _WebClient.Headers.Add(("Content-Type"), "pdf")
    
    
                ' _WebClient.Headers["A_url"] = "pdf";
    
    
                '_WebClient.Headers["ContentType"] = "pdf";
    
                _WebClient.DownloadFile(A_URL, B_SAVEAS)
    Hi Team,

    i am using the above code to download a pdf report generated in the attached link (url) i could see a file generated in the destination with the given name . However i am unable to open the newly saved file .

    then i started using ..._WebClient.H eaders.Add(("Co ntent-Type"), "pdf")

    even after i get same kind of error while opening the pdf report. i am trying to save whatever is there in the link . Link actually opens a PDF file , i want to save that copy in the server for reference. Let me know if you have any change that i need to make in my above code ?
    i have got a smiliar link from bytes.com which is

    http://bytes.com/topic/asp-net/answers/345837-system-net-webclient-downloadfile-doesnt-work-http-attachments

    however its C# we are working in VB.

    Any help will be great for me.

    Best REgards
    Jinson
Working...