public void AutoOrderExtract() { if (txtFromDate.SelectedDate != null) { fromdate = DateTime.Parse(txtFromDate.SelectedDate.ToString()); } if (txtToDate.SelectedDate != null) { todate = DateTime.Parse(txtToDate.SelectedDate.ToString()); } string dailyDirName = ddlOrderType.SelectedItem.Text + @"_" + ddlType.SelectedItem.Text; string extractPath = ConfigurationSettings.AppSettings["RTA_EXTRACT_PATH"]; string downloadFileName = ddlType.SelectedValue == "FCS" ? "CAMS_SM" : "DOC_0011" + todate.ToString("ddMMyyy"); string localFilePath = onlineOrderBackOfficeBo.GenerateDailyOrderFATCASummaryFiles(Server.MapPath("~/ReferenceFiles/RTAExtractSampleFiles/"), ddlOrderType.SelectedValue, ddlType.SelectedValue, adviserVo.advisorId, fromdate, todate); if (File.Exists(extractPath + @"\" + adviserVo.advisorId + @"\" + downloadFileName + ".DBF") == true) { System.IO.File.Delete(extractPath + @"\" + adviserVo.advisorId + @"\" + downloadFileName + ".DBF"); } File.Copy(localFilePath, extractPath + @"\" + adviserVo.advisorId + @"\" + downloadFileName + ".DBF"); System.Threading.Thread.Sleep(1000); if (string.IsNullOrEmpty(localFilePath)) { ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('No Data Available to download');", true); return; } Response.ContentType = "application/dbf"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + downloadFileName + ".DBF"); string aaa = extractPath + @"\" + adviserVo.advisorId + @"\" + downloadFileName + ".DBF"; Response.TransmitFile(extractPath + @"\" + adviserVo.advisorId + @"\" + downloadFileName + ".DBF"); HttpContext.Current.ApplicationInstance.CompleteRequest(); Response.End(); }