The following code creates a Download button that allows users to download a file:

<asp:Button ID="btnDownload" Text="Download File" OnClick="btnDownload_Click" runat="server" />

This is a method DownloadFile that does the job:

private void DownloadFile(string path, string filename, string mimeType)
    HttpResponse response = HttpContext.Current.Response;
    string fullPath = HttpContext.Current.Server.MapPath(Path.Combine(path, filename));

    // Read the file to a byte array.
    byte[] buffer;
    using (FileStream stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
        // Create a buffer to hold the stream bytes.
        buffer = new byte[stream.Length];

        // Read the bytes from the stream.
        stream.Read(buffer, 0, (int)stream.Length);
    } // stream.Close() is called automatically

    // Add HTTP header.
    response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
    response.ContentType = mimeType;

    // Call End() rather than CompleteRequest() despite a suggestion at MSDN:

    // If you called HttpContext.Current.ApplicationInstance.CompleteRequest()
    // the page's HTML would be attached at the end of the downloaded file.

A button's click handler simply calls the DownloadFile method providing proper parameters (we assume there is a file MyFile.txt located in a folder Downloads):

protected void btnDownload_Click(object sender, EventArgs e)
    DownloadFile("~/Downloads", "MyFile.txt", "text/plain"); // example: application/zip

You can download entire code from here