Hello guys,
I need one help. I have written a code for downloading files on a given link. Single file download is working properly. but i want to create a functionality for download all. User can check multiple files and then when he selects download button it should download all the selected files automatically.
regards,
My current Code :
Code:Dim strRequest() As String '= Request.QueryString("file") '-- if something was passed to the file querystring Dim i As Integer strRequest = Split("YServer.txt,PkgClnup.log", ",") For i = 0 To UBound(strRequest) Response.Write(Server.MapPath(strRequest(i)) & " : " & i) If strRequest(i) <> "" Then 'get absolute path of the file Dim path As String = Server.MapPath(strRequest(i)) 'get file object as FileInfo 'Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server Dim fs As FileStream fs = File.Open(path, FileMode.Open) Dim bytBytes(fs.Length) As Byte fs.Read(bytBytes, 0, fs.Length) fs.Close() Response.AddHeader("Content-Disposition", "attachment; filename=" & strRequest(i)) 'Response.AddHeader("Content-Length", File.Length.ToString()) Response.ContentType = "APPLICATION/OCTET-STREAM" Response.Flush() Response.BinaryWrite(bytBytes) Response.Clear() Response.ClearHeaders() Response.ClearContent() Else Response.Write("Please provide a file to download.") End If Response.End() 'if file does not exist Next


Reply With Quote
Bookmarks