private void DownloadFile(string fname, bool forceDownload) { // string path = MapPath(fname); string name = Path.GetFileName(fname); string ext = Path.GetExtension(fname); string type = ""; // set known types based on file extension if (ext != null) { switch (ext.ToLower()) { case ".htm": case ".html": type = "text/HTML"; break; case ".txt": type = "text/plain"; break; case ".doc": case ".rtf": case ".docx": type = "Application/msword"; break; } } if (forceDownload) { Response.AppendHeader("content-disposition", "attachment; filename=" + name); } if (type != "") Response.ContentType = type; Response.WriteFile(fname); Response.End(); } protected void linkdownload_Click(object sender, EventArgs e) { objCandidate.IntJobseekerid = Convert.ToInt32(Session["JobSeekerId"]); dsCandidate = objCandidate.SelectJSProfileEduInfoByJobseekerId(); if ((dsCandidate.Tables[0].Rows[0]["ResumeFile"]).ToString().Trim().Length > 0) { string DirPath; DirPath = Server.MapPath("./Resume/"); string databasename=(dsCandidate.Tables[0].Rows[0]["ResumeFile"]).ToString(); string destinationfile=DirPath+databasename; string extnsn=(dsCandidate.Tables[0].Rows[0]["ResExtnsn"]).ToString(); int Eduid=Convert.ToInt32(dsCandidate.Tables[0].Rows[0]["ProfileEduId"]); //string filename = dsCandidate.Tables[0].Rows[0]["ResumeFile"].ToString(); string folderfile = "Resume" + Eduid.ToString() + extnsn; string sourcefile=DirPath+folderfile; if (File.Exists(destinationfile) == true) { File.Delete(destinationfile); } if (File.Exists(sourcefile) == true) { File.Copy(sourcefile, destinationfile); string filename = databasename; //uploadresume.SaveAs(Path.Combine(DirPath, "Resume" + i.ToString() + Path.GetExtension(uploadresume.FileName).ToLower())); DownloadFile(DirPath + filename, true); File.Delete(destinationfile); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)