Hi Abhisekjani,
by keeping in assumption that your file is in WEBSERVER. Please find the below function and call this function in button click .let me know if you need any further help.
VB.NET
====================================================================
Function DownloadFile(ByVal FileName As String)
Dim path As String = Server.MapPath("/Attachments/") + FileName
If System.IO.File.Exists(path) = True Then
Dim file As System.IO.FileInfo = New System.IO.FileInfo(path)
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End()
End If
End Function
====================================================================
C SHARP CODE
====================================================================
public object DownloadFile(string FileName)
{
string path = Server.MapPath("/Attachments/") + FileName;
if (System.IO.File.Exists(path) == true) {
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
}
Thanks & Regards,
Ravindra M
(Success Always Depends on Dedication & Commitment)
Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator