Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I'm doing a consultancy site in which the candidates can upload their cv.& stored in a folder in the server.Now when the site admin enters he has to select a PARTICULAR CV at a time to download from the folder saved in the godaddy acct to his PC.I searched a lot of similar activities.But I couldn't understand it clearly.Could any one give me a suggestion about how to implement this download portion in my webpage.

Thanks in Advance

Dhanya
Posted
Comments
Sergey Alexandrovich Kryukov 16-Jun-11 13:29pm    
Do you need HTTP or what?
--SA

Go through the following link.
File Download[^]
 
Share this answer
 
If you need HTTP download, you can use my HTTPDownloader application for sample. I posted full source code in my past answer:
how to download a file from internet[^].

Even though this is a console application, you can take just the downloading code which is simple enough. One important feature is implemented: possibility to continues download of partially downloaded file, if the process was broken in the middle, before download of a file is complete.

Now, if you want FTP download, the code is different.

One option is using WebRequestMethods.Ftp.DownloadFile: http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp.downloadfile.aspx[^].

Another option is using FtpWebRequest class: http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx[^].

—SA
 
Share this answer
 
Comments
bhupathy2807 22-Jun-12 4:53am    
how to download a file from the server in Asp.net..?
Sergey Alexandrovich Kryukov 29-Jun-12 20:43pm    
Exact same way, no difference; even though everything is done on HTTP request from the client side, it does not make any difference in download itself: you do it on server side and download to server; later you can do anything else to it...
--SA
Try This One..
C#
string filepath = Server.MapPath("-- File Path Here --");
// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo myfile = new FileInfo(filepath);

// Checking if file exists
if (myfile.Exists)
{

// Clear the content of the response
Response.ClearContent();

// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.Name);

// Add the file size into the response header
Response.AddHeader("Content-Length", myfile.Length.ToString());

// Set the ContentType
//    Response.ContentType = ReturnExtension(myfile.Extension.ToLower());

// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(myfile.FullName);

// End the response
Response.End();

}

If You Doubts Replay Me Back..
 
Share this answer
 
v3
Comments
Uday P.Singh 16-Jun-11 6:44am    
good answer my 5 :)
Prasad CM 16-Jun-11 6:47am    
Thank U Uday..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900