Ravi Patel

Ravi Patel

  • 247
  • 6.8k
  • 1.4m

select the folder where you want to save the download

Jul 23 2014 7:15 AM
Hi all,

i want to download  some files  from server folder  and i want to give option  to client so that he can   select the folder where he  want to save the downloaded files    but  files are downloading in default folder (download)    
 
 Dim strRequest As String = Request.QueryString("file") '-- if something was passed to the file querystring
    If strRequest <> "" Then 'get absolute path of the file
        Dim path As String = Server.MapPath(strRequest) 'get file object as FileInfo
        Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server
        If file.Exists Then 'set appropriate headers
            Response.Clear()
            Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
            Response.AddHeader("Content-Length", file.Length.ToString())
            Response.ContentType = "application/octet-stream"
            Response.WriteFile(file.FullName)
            Response.End 'if file does not exist
        Else
            Response.Write("This file does not exist.")
        End If 'nothing in the URL as HTTP GET
    Else
        Response.Write("Please provide a file to download.")
    End If


it is downloding in default folder but i want to give option  to client so that he can   select the folder where he  want to save the downloaded files