473,387 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to download multiple files

I have a asp.net app where a user will need to download multiple files at
once.

Below is some sample code I'm using to download a single file which works
perfectly, however, rather than a single file, I need to download all the
image files for a single order being processed by the user. Is it possible
to download a batch or group of files?

Thanks.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

Dim sFilePath As String
Dim oFile As IO.FileInfo

'sFilePath = Request.QueryString.Item("FilePath")
sFilePath =
"C:\Inetpub\wwwroot\Charmpix\Images\ItemImages\Cus tomPhotos\21207
_Image1.JPG"
oFile = New System.IO.FileInfo(sFilePath)

' Clear the current output content from the buffer
Response.Clear()

' Specify that the response is a stream that cannot be read by the
client and must be downloaded
'Response.ContentType = "application/octet-stream"
Response.ContentType = "application/octet-stream; name=" &
oFile.Name

' Add the header that specifies the default filename for the
Download/SaveAs dialog
'Response.AddHeader("Content-Disposition", "attachment filename=" &
oFile.Name)
Response.AddHeader("content-disposition", "attachment;filename=" &
oFile.Name)

' Add the header that specifies the file size, so that the browser
can show the download progress
Response.AddHeader("Content-Length", oFile.Length.ToString())

' Send the file stream to the client
Response.WriteFile(oFile.FullName)

' Stop the execution of this page
Response.End()

End Sub


--
mo*******@nospam.com
Nov 18 '05 #1
2 13106
The simplest way would probably be to put all the files into one zip file.
Then it's still easy with only one file to download.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"moondaddy" <mo*******@nospam.com> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
I have a asp.net app where a user will need to download multiple files at
once.

Below is some sample code I'm using to download a single file which works
perfectly, however, rather than a single file, I need to download all the
image files for a single order being processed by the user. Is it possible to download a batch or group of files?

Thanks.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

Dim sFilePath As String
Dim oFile As IO.FileInfo

'sFilePath = Request.QueryString.Item("FilePath")
sFilePath =
"C:\Inetpub\wwwroot\Charmpix\Images\ItemImages\Cus tomPhotos\21207
_Image1.JPG"
oFile = New System.IO.FileInfo(sFilePath)

' Clear the current output content from the buffer
Response.Clear()

' Specify that the response is a stream that cannot be read by the
client and must be downloaded
'Response.ContentType = "application/octet-stream"
Response.ContentType = "application/octet-stream; name=" &
oFile.Name

' Add the header that specifies the default filename for the
Download/SaveAs dialog
'Response.AddHeader("Content-Disposition", "attachment filename=" & oFile.Name)
Response.AddHeader("content-disposition", "attachment;filename=" &
oFile.Name)

' Add the header that specifies the file size, so that the browser
can show the download progress
Response.AddHeader("Content-Length", oFile.Length.ToString())

' Send the file stream to the client
Response.WriteFile(oFile.FullName)

' Stop the execution of this page
Response.End()

End Sub


--
mo*******@nospam.com

Nov 18 '05 #2
Hi Moondaddy,

As for the download multifiles problem you mentioned, I think Steve's
suggestion that use a certain zip file to provide the multi-file download
is reasonable since the Web page's response is stream based and each
request will only return a single response stream. And we generally put
html stream as output when return web page and return a certain file stream
when process file download request. But it's not suitable to put mutlit
file's stream into one response stream since the client browser is unable
to parse it out.
Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Ken | last post by:
How do I download files from the internet server to my computer? How do I tell the script the correct hard drive folder on my computer to copy the files to? After connecting to the internet...
4
by: Billy Jacobs | last post by:
Is there a way to download multiple files from a server? If not then: How do I zip up multiple files using the .net classes in vb? Thanks Billy Jacobs
2
by: Ivo Tcholakov | last post by:
Hello, I created an application where the users need to download files. I have the list of the files stored in a database and I present the list to download in a Datagrid. Here comes my question....
2
by: RJN | last post by:
Hi I need help in allowing the user to download multiple files at once. User will be displayed a grid on the browser which will list the various files available on the web server for download...
1
by: RJN | last post by:
Hi Sorry for posting this again. Requirement is to allow the user to download multiple files at once from browser. User will be displayed a grid on the browser which will list the various files...
5
by: Stanav | last post by:
Hello all, Thanks in advance for any replies... Now, my question is: Is it possible to do a multiple files download for a single response event on an aspx page? If there is, please give me some...
5
by: gjzusenet | last post by:
Hello. Though Python supports threading, I think it is limited to python code - as soon as you issue a command that uses an external (C?) module, all of your python threads hang until this command...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
6
by: empiresolutions | last post by:
Using the following code, files greater than 10Megs do not download. Less than 10 is working. Can anyone explain why? Files that will be downloaded are 5G plus in size. function download() {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.