473,566 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

Dim sFilePath As String
Dim oFile As IO.FileInfo

'sFilePath = Request.QuerySt ring.Item("File Path")
sFilePath =
"C:\Inetpub\www root\Charmpix\I mages\ItemImage s\CustomPhotos\ 21207
_Image1.JPG"
oFile = New System.IO.FileI nfo(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.Conte ntType = "applicatio n/octet-stream"
Response.Conten tType = "applicatio n/octet-stream; name=" &
oFile.Name

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

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

' Send the file stream to the client
Response.WriteF ile(oFile.FullN ame)

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

End Sub


--
mo*******@nospa m.com
Nov 18 '05 #1
2 13156
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*******@nosp am.com> wrote in message
news:Oy******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

Dim sFilePath As String
Dim oFile As IO.FileInfo

'sFilePath = Request.QuerySt ring.Item("File Path")
sFilePath =
"C:\Inetpub\www root\Charmpix\I mages\ItemImage s\CustomPhotos\ 21207
_Image1.JPG"
oFile = New System.IO.FileI nfo(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.Conte ntType = "applicatio n/octet-stream"
Response.Conten tType = "applicatio n/octet-stream; name=" &
oFile.Name

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

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

' Send the file stream to the client
Response.WriteF ile(oFile.FullN ame)

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

End Sub


--
mo*******@nospa m.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
3610
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 server, I am trying: $_SESSION = "/uploaddir/"; // directory on server $_SESSION = "c:/_picture_file/"; // directory on computer
4
2363
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
2163
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. How can I make it possible that the user selects multiple files and downloads them at once instead of clicking on every file to download? With...
2
1478
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 and a check box beside each. User will select the files that are to be downloaded. On click of start button, user should be prompted for the path...
1
3193
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 available on the web server for download and a check box beside each for selecting the file. I have received replies that this can be done by an...
5
3667
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 directions/sample code or anything. On my web application, I have a CheckBoxList that shows all the files. The user will check (select) the files...
5
2389
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 returns. Is that true? I'm using urllib2 to download many files, and I have a double problem: 1. downloading all of them is painfully slow since...
2
6937
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
6
1667
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() { global $_GET; //Gather relevent info about file $file = "/user/dac420/tts/incoming/".$_GET; $len =...
0
7673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.