ASP.NET File Uploader is an easy to use control. Just drag and drop
the control on your page and write this code snippet at Button Click
Event to upload the file.
To download file use this code snippet Link Button or Button Click event.
if (studentFileUpload.HasFile == true)
{
string filename = Path.GetFileName(studentFileUpload.FileName);
studentFileUpload.SaveAs(Server.MapPath("~/DataFile/") + filename);
}
To download file use this code snippet Link Button or Button Click event.
protected void DownloadLinkButton_Click(object sender, EventArgs e)
{
string fileName = fileNameLabel.Text;
string filePath = Server.MapPath("~/DataFile/" + fileName + ".txt");
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath));
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.WriteFile(filePath);
HttpContext.Current.Response.End();
}
Industrial Training in jaipur for MCA or btech student : Chipsoul Web Solution
No comments:
Post a Comment