473,387 Members | 1,493 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 a file from Server to client

ad
How can I download a file form Server to client?
May 31 '06 #1
8 6313
Using what protocol?

You could quite easily use WebClient.DownloadFile() to download a file over
HTTP .. is there some specific way you are looking to download this file?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
How can I download a file form Server to client?

May 31 '06 #2
ad
Thanks,

I want to download file from the virtual directory of my web application.
The file name is mine.zip.
But the first parameter of the WebClient.DownloadFile is URI.

How can I give the first parameter of the WebClient.DownloadFile() ?
"Greg Young" <dr*******************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:OB**************@TK2MSFTNGP03.phx.g bl...
Using what protocol?

You could quite easily use WebClient.DownloadFile() to download a file
over HTTP .. is there some specific way you are looking to download this
file?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
How can I download a file form Server to client?


Jun 1 '06 #3
There is also a string version ..

http://msdn2.microsoft.com/en-us/lib...nloadfile.aspx

The URI method also has a constructor which takes a string I believe.

Cheersm

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:em****************@TK2MSFTNGP02.phx.gbl...
Thanks,

I want to download file from the virtual directory of my web application.
The file name is mine.zip.
But the first parameter of the WebClient.DownloadFile is URI.

How can I give the first parameter of the WebClient.DownloadFile() ?
"Greg Young" <dr*******************@hotmail.com>
¼¶¼g©ó¶l¥ó·s»D:OB**************@TK2MSFTNGP03.phx.g bl...
Using what protocol?

You could quite easily use WebClient.DownloadFile() to download a file
over HTTP .. is there some specific way you are looking to download this
file?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
How can I download a file form Server to client?



Jun 1 '06 #4
ad
It will not ask user when I use WebClient.DownloadFile do download a file
from server.
But I wnat that the user can confirm before download.
How can I do ?
"Greg Young" <dr*******************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:eD**************@TK2MSFTNGP04.phx.g bl...
There is also a string version ..

http://msdn2.microsoft.com/en-us/lib...nloadfile.aspx

The URI method also has a constructor which takes a string I believe.

Cheersm

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:em****************@TK2MSFTNGP02.phx.gbl...
Thanks,

I want to download file from the virtual directory of my web application.
The file name is mine.zip.
But the first parameter of the WebClient.DownloadFile is URI.

How can I give the first parameter of the WebClient.DownloadFile() ?
"Greg Young" <dr*******************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:OB**************@TK2MSFTNGP03.phx.g bl...
Using what protocol?

You could quite easily use WebClient.DownloadFile() to download a file
over HTTP .. is there some specific way you are looking to download this
file?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
How can I download a file form Server to client?



Jun 1 '06 #5
Erm, perhaps by using a MessageBox.Show before calling DownloadFile?

Or have we miunderstood your usage? (and to be fair, Greg did ask, but you
didn't answer). Is the client an app or a browser? (it makes a big
difference).

Marc
Jun 1 '06 #6
ad
Sorry,
The client is browser.
"Marc Gravell" <ma**********@gmail.com> ¼¶¼g©ó¶l¥ó·s»D:OV**************@TK2MSFTNGP02.phx.g bl...
Erm, perhaps by using a MessageBox.Show before calling DownloadFile?

Or have we miunderstood your usage? (and to be fair, Greg did ask, but you
didn't answer). Is the client an app or a browser? (it makes a big
difference).

Marc

Jun 1 '06 #7
OK then; various options:

If the file itself is publicly available on the web-site, then you could
just hyperlink to it (assuming that MIME is a download type, not an inline
type)
Another similar option is to use HttpResponse.TransmitFile; this will push
the file back to the client on the current response.
To prompt for a download box, you want to set the "content-disposition" HTTP
header to "attachment; filename=something.blah" - this should make the
browser display a "Save As..." dialog to save the current response to disk.
You may be able to use this with TransmitFile, and if it fails you could
just pump the stream yourself.
Another way is to change the "content-type" header to
"application/octet-stream"; this catch-all MIME type is generally prompted
to save, but it gives less information about what the file really is. One
advantage, however, is that it /might/ (not definite; haven't tried it) be
possible to set this as a customer header on a folder on your web-server -
so that everything in (for instance) /Download/ gets this MIME type and thus
is prompted for save.

Some starters for 10 ;-p

Marc
Jun 1 '06 #8
customer = custom; damned spell checker
Jun 1 '06 #9

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

Similar topics

1
by: ian maclure | last post by:
I'm writing a client-server app. Client controls Server which in turn configures and controls a bunch of hardware. I want to be able to start the server from my client. Now in C/C++ one could...
3
by: Tim Cowan | last post by:
Hi I have a script in ASP 3.0 which creates a CSV file on the server. After the code has run I want it to prompt the user to download the file (via the browser). I have spent a frustrating hour...
3
by: EK | last post by:
I am trying to use asp to download a file located on a different server. I can use ADODB.Stream, LoadFromFile(\\Server\Something) and the Response.BinaryWrite successfully, but only if I create an...
6
by: Nimesh | last post by:
Hi All, I am new to ASP.NET. I need to download a file from server to the client machine. Any ideas on how to go about this ? Thanks In Advance.
0
by: Hans | last post by:
I have an asp site which I try to bet unicode compatible (UTF-8 codepage=65001). In the site a user can upload documents and I store the document on the server in a database. I also store the...
1
by: Matt Hamilton | last post by:
I was hoping that someone can give me step-by-step instructions to fix the following: We would like our ASP.NET application to utilize a central file server for uploads and downloads. I have...
10
by: Paul | last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a server. I have a browse to find the file on the server but need to create the path dynamically as to were it will go...
12
by: SAL | last post by:
Hello, Is it possible to read a CSV from the Client, and bind my Datagrid to the data in the CSV file without uploading the file to the Server first? I have tried and in Debug mode on my...
0
by: ankuragt | last post by:
(problem in writing a string into a file on client side.) hey i have written a code of server and client.what i want to do is to transfer the contents of file on server side to the client side (line...
5
by: captainB | last post by:
Hi, I'm building a simple online image gallery that allows users to download full size images for free with one condition - they must submit their name and why the chose the image. I want to use a...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.