Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
If e.CommandName = "Down" Then

         Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
         Dim lblDoc = TryCast(row.FindControl("lbllog"), Label).Text
         Dim cs = "172.16.16.21/"

         Dim lblDoca = cs + "D:/1 Application/MobileApp/Documents/B2C 158712858622501161001263110.jpg"
         ''Dim lblDoca = cs + lblDoc


         Response.ContentType = ContentType
         Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(lblDoca))
         Response.WriteFile(lblDoca)
         Response.End()


What I have tried:

actually i want to download image which is another server..how can i download it
Posted
Updated 3-Apr-17 4:09am
Comments
ZurdoDev 3-Apr-17 7:03am    
You need to start with a valid path to the file.
Member 12300036 3-Apr-17 7:09am    
didn get u

VB
Dim webClient As New System.Net.WebClient()
webClient.DownloadFile("http://<serverPath>/<filename>.txt", "<localpath2save>")


For Example :

<serverpath> : http://www.testserver.com (like => http://192.168.9.99:1880/testfolder/test.txt)
<filename> : test
<localpath2save> : C:\\test.txt
 
Share this answer
 
Comments
Member 12300036 4-Apr-17 23:45pm    
it is not working
Member 12300036 4-Apr-17 23:53pm    
showing error:The given path's format is not supported.
Member 12300036 5-Apr-17 6:39am    
ok now working...bt now showing downloding on browser direct save to local folder that i provided
1. You need to give valid path and include response modify the content type to download the image type
2. On the other server where file is located, you need to have permission to access the file

String filename = (String) request.getAttribute("fileName");
       response.setContentType("application/octet-stream");
       response.setHeader("Content-Disposition",
               "attachment;filename="+filename);
 
Share this answer
 
v2
Comments
Kats2512 3-Apr-17 8:18am    
The code in the question is VB, why did you post C#? and enquirer already has this snippet of code in the question so this makes no difference
Member 12300036 4-Apr-17 23:56pm    
not working

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