473,398 Members | 2,343 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,398 software developers and data experts.

Downloading

Hi,

This has probably been discussed before, but I have been unable to find
anything on it, except an article written in C or C+, or C# and not in VB.

How can I download a file from my web page to a client?

Thanks in advance.

Ken
Nov 19 '05 #1
4 1114
Dear kan,

There are many ways to download a web file (remote file). The best way, i
ever invent in dotnet is to do it with webclient object.

This object provides you many methods for download data, you can also
download a file as a data or can also download file using
webclient.DownloadData(URL) method or DownloadFile(URL).

In C# or vb.net you can use this. The other thing, you can also provide
credential for those web location which have some authentication, windows or
whatever.
--
Wajahat Abbas
http://wajahatabbas.blogspot.com
"Kenneth Windish" wrote:
Hi,

This has probably been discussed before, but I have been unable to find
anything on it, except an article written in C or C+, or C# and not in VB.

How can I download a file from my web page to a client?

Thanks in advance.

Ken

Nov 19 '05 #2
Hi Kenneth,

In order to download files to a user machine you can use the following code snippet to do so:

Dim FilePath As String = Server.MapPath("abc.txt")
& nbsp;Dim TargetFile As New System.IO.FileInfo(FilePath)

' clear the current output content from the buffer
Response.Clear()
' add the header that specifies the default filename for the Download/
' SaveAs dialog
Response.AddHeader("Content-Disposition", "attachment; filename=" + _
TargetFile.Name)
' add the header that specifies the file size, so that the browser
' can show the download progress
Response.AddHeader("Content-Length", TargetFile.Length.ToString())
' specify that the response is a stream that cannot be read by the
' client and must be downloaded
Response.ContentType = "application/octet-stream"
' send the file stream to the client
Response.WriteFile(TargetFile.FullName)
' stop the execution of this page
Response.End()

HTH

Mona[Grapecity]

"Kenneth Windish" <ke************@netzero.net> wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl...
Hi,

This has probably been discussed before, but I have been unable to find
anything on it, except an article written in C or C+, or C# and not in VB.

How can I download a file from my web page to a client?

Thanks in advance.

Ken

Nov 19 '05 #3
Hi,

That's exactly what I needed and it works great.
Thanks for the help.

Ken

"Mona" <mo**@discussion.com> wrote in message news:eV**************@TK2MSFTNGP15.phx.gbl...
Hi Kenneth,

In order to download files to a user machine you can use the following code snippet to do so:

Dim FilePath As String = Server.MapPath("abc.txt")
& nbsp;Dim TargetFile As New System.IO.FileInfo(FilePath)

' clear the current output content from the buffer
Response.Clear()
' add the header that specifies the default filename for the Download/
' SaveAs dialog
Response.AddHeader("Content-Disposition", "attachment; filename=" + _
TargetFile.Name)
' add the header that specifies the file size, so that the browser
' can show the download progress
Response.AddHeader("Content-Length", TargetFile.Length.ToString())
' specify that the response is a stream that cannot be read by the
' client and must be downloaded
Response.ContentType = "application/octet-stream"
' send the file stream to the client
Response.WriteFile(TargetFile.FullName)
' stop the execution of this page
Response.End()

HTH

Mona[Grapecity]

"Kenneth Windish" <ke************@netzero.net> wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl...
Hi,

This has probably been discussed before, but I have been unable to find
anything on it, except an article written in C or C+, or C# and not in VB.

How can I download a file from my web page to a client?

Thanks in advance.

Ken

Nov 19 '05 #4
Hi,

Whew. My heads still spinning. Web Client objects..... sounds pretty
complicated. Thanks for the info though, might look into out of curiosity.

Later

Ken

"Wajahat Abbas" <wa**********@yahoo.com.blogspot> wrote in message
news:71**********************************@microsof t.com...
Dear kan,

There are many ways to download a web file (remote file). The best way, i
ever invent in dotnet is to do it with webclient object.

This object provides you many methods for download data, you can also
download a file as a data or can also download file using
webclient.DownloadData(URL) method or DownloadFile(URL).

In C# or vb.net you can use this. The other thing, you can also provide
credential for those web location which have some authentication, windows
or
whatever.
--
Wajahat Abbas
http://wajahatabbas.blogspot.com
"Kenneth Windish" wrote:
Hi,

This has probably been discussed before, but I have been unable to find
anything on it, except an article written in C or C+, or C# and not in
VB.

How can I download a file from my web page to a client?

Thanks in advance.

Ken

Nov 19 '05 #5

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

Similar topics

4
by: Luke StClair | last post by:
Only marginally belonging in this newsgroup... but oh well. I've just started writing in python, and I want to make the files available on the web. So I did the standard <a...
2
by: Dave | last post by:
Dear Sirs, Is there a way to get the width and height of an image without downloading the image, or with just downloading a minimal portion of the image? For instance, I have a list of 10,000...
0
by: TJ | last post by:
Hi, I've written code web-based uploading and downloading. Here is some code for it. For saving file into MS-SQL database, SaveFileIntoDB(HttpPostedFile file) { int fileLength =...
2
by: Bala | last post by:
Hi I am trying to download the PDF files from my webserver using ASP.Net. All my files are stored at F Drive on webserver. Like this F:\Main Folder\Sub Folder\Files\File1.pdf I am...
4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
3
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
5
by: fniles | last post by:
We created an ActiveX control and marked it as safe for scripting using Implements IObjectSafety. We then created a CAB file and signed it using Verisign. We also created a license file (LPK file)...
0
by: just.starting | last post by:
I am having problem while downloading files from an apache server2.0.53 with php4.3.10.While downloading some files it generally stops after downloading some specific amount and then stops...
23
by: Doug van Vianen | last post by:
Hi, Is there some way in JavaScript to stop the downloading of pictures from a web page? Thank you. Doug van Vianen
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
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...

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.