protected void Button1_Click(object sender, EventArgs e) { byte[] strPath = Convert.FromBase64String(TextBox1.Text); string pass = EncryptionClass.DecryptRJ256(strPath); Response.Write(pass); }
public ActionResult Index() { var h = "EsSWxhhkcqfIvh4n1K83DOQynZmnoH3XvZo1APFl6/w="; var user = "******"; var hash = EncryptionClass.EncryptPass(user); var decrypt = EncryptionClass.DecryptPass(h); //JOPsUBHAck9T8bb96DGtLg == byte[] base64HashesPassword = Convert.FromBase64String(h); string pass = EncryptionClass.DecryptRJ256(base64HashesPassword); var decrypt256 = EncryptionClass.EncryptRJ(h); //DecryptRJ256 return(View()); }
byte[] GeneratPdf(DataRow row) { string did = "-1"; string QuesId = "-1"; int? cityId = null; int q2Status = -1; int q1Status = -1; string fullPathZipFile; //=================================== did = row["coursecode"].ToString(); QuesId = row["QuestionId"].ToString(); cityId = int.Parse(row["cityId"].ToString()); q2Status = int.Parse(row["q2Status"].ToString()); q1Status = int.Parse(row["Status"].ToString()); int?cityIDQ2 = null; if (q2Status != -1 && q1Status == 3) { cityIDQ2 = cityId; } var quizPapere = EBusiness.ShowQueizPaperByDid(did, cityIDQ2); var dynamicPath = "~/QueizPapers/" + quizPapere.Rows[0]["tterm"].ToString() + "/" + quizPapere.Rows[0]["code_ostad"].ToString() + "/pdffiles/" + quizPapere.Rows[0]["coursecode"].ToString(); string path = Server.MapPath(dynamicPath); if (cityIDQ2 == -1) { fullPathZipFile = $"{path}/{did.ToString()}_canceled_1.zip"; } else if (cityIDQ2 > 0) { fullPathZipFile = $"{path}/{did.ToString()}_canceled_2.zip"; } else { fullPathZipFile = $"{path}/{did.ToString()}.zip"; } byte[] base64HashesPassword = Convert.FromBase64String(quizPapere.Rows[0]["Password"].ToString()); string pass = EncryptionClass.DecryptRJ256(base64HashesPassword); var item = EBusiness.GetExamQuestionsbyDid(did, null, cityIDQ2); var whiteTape = Server.MapPath("~/University/Theme/images/whitePaper.jpg"); var questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg"); var examQ_Detail = EBusiness.Get_ExamdetailbyDid(did, null, cityIDQ2); var constQuestionFileInfo = new ExamStudentDTO(); constQuestionFileInfo.TypeNimsal = examQ_Detail.Rows[0]["typeNimsal"].ToString(); constQuestionFileInfo.CourseTitle = examQ_Detail.Rows[0]["namedars"].ToString(); constQuestionFileInfo.ProfossorFullName = examQ_Detail.Rows[0]["osname"].ToString(); constQuestionFileInfo.ExamDate = examQ_Detail.Rows[0]["dateexam"].ToString(); constQuestionFileInfo.ExamTime = examQ_Detail.Rows[0]["saatexam"].ToString(); constQuestionFileInfo.KeyCode = examQ_Detail.Rows[0]["keyCode"].ToString(); constQuestionFileInfo.ExamDuration = examQ_Detail.Rows[0]["examTime"].ToString(); constQuestionFileInfo.Calculator = examQ_Detail.Rows[0]["calculator"].ToString(); constQuestionFileInfo.Note = examQ_Detail.Rows[0]["note"].ToString(); constQuestionFileInfo.LowBook = examQ_Detail.Rows[0]["LowBook"].ToString(); constQuestionFileInfo.ClassCode = examQ_Detail.Rows[0]["ClassCode"].ToString(); constQuestionFileInfo.Grade = examQ_Detail.Rows[0]["magh"].ToString(); constQuestionFileInfo.Major = examQ_Detail.Rows[0]["nameresh"].ToString(); var userID = Session[sessionNames.userID_Karbar].ToString(); EBusiness.ChangeTemplateOfQuestion(path, did.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID, cityIDQ2); var generatedPdfPath = (Server.MapPath($"{dynamicPath}/{userID}/{did}_Momtahen_{userID}_1.pdf")); fileByteArray = System.IO.File.ReadAllBytes(generatedPdfPath); //Directory.GetDirectories(path).ToList().ForEach(dir => Directory.Delete(dir, true)); //File.Delete(generatedPdfPath); return(fileByteArray); }
protected void grd_CourseList_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridDataItem) { //GridDataItem dataItem = e.Item as GridDataItem; //GridDataItem item = (GridDataItem)e.Item; Button btnDlQuestionSinglePage = e.Item.FindControl("btnDlQuestionSinglePage") as Button; Button btnDlQuestionMergedFiles = e.Item.FindControl("btnDlQuestionMergedFiles") as Button; Button btnDlQuestionMainFormat = e.Item.FindControl("btnDlQuestionMainFormat") as Button; TextBox lbl_Password = e.Item.FindControl("lbl_Password") as TextBox; HiddenField hdn_Pass = e.Item.FindControl("hdn_Pass") as HiddenField; HiddenField hdn_IsActive = e.Item.FindControl("hdn_IsActive") as HiddenField; HiddenField hdn_ApproveNewHeader = e.Item.FindControl("hdn_ApproveNewHeader") as HiddenField; var dtUserRoles = getCurrentUserRoles(Session[sessionNames.userID_Karbar].ToString()); if (dtUserRoles != null && dtUserRoles.Rows.Count > 0) { //var isRole_1_32_33 = false; //for (int i = 0; i < dtUserRoles.Rows.Count; i++) //{ // if (dtUserRoles.Rows[i]["RoleId"].ToString() == "1" // || dtUserRoles.Rows[i]["RoleId"].ToString() == "32" // || dtUserRoles.Rows[i]["RoleId"].ToString() == "33") // { // isRole_1_32_33 = true; // break; // } //} //if (isRole_1_32_33) //{ // if (!string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) && hdn_ApproveNewHeader.Value == "False") // { // btnDlQuestionMainFormat.Visible = true; // } // else // { // btnDlQuestionSinglePage.Visible = true; // } //} //else { //TODO if ApproveNewHeader value is false then just show old header if (!string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) && hdn_ApproveNewHeader.Value == "False") { btnDlQuestionMainFormat.Visible = true; } else if (string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) || hdn_ApproveNewHeader.Value == "True") //TODO else ApproveNewHeader is true or Null then { //TODO if permision is true show new header and total new header if (!string.IsNullOrEmpty(hdn_IsActive.Value) && hdn_IsActive.Value == "1") { btnDlQuestionSinglePage.Visible = true; btnDlQuestionMergedFiles.Visible = true; } else if (string.IsNullOrEmpty(hdn_IsActive.Value) || hdn_IsActive.Value == "0")//TODO else permision is false or null total new header { btnDlQuestionMergedFiles.Visible = true; } } } } else { //TODO if ApproveNewHeader value is false then just show old header if (!string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) && hdn_ApproveNewHeader.Value == "False") { btnDlQuestionMainFormat.Visible = true; } else if (string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) || hdn_ApproveNewHeader.Value == "True") //TODO else ApproveNewHeader is true or Null then { //TODO if permision is true show new header and total new header if (!string.IsNullOrEmpty(hdn_IsActive.Value) && hdn_IsActive.Value == "1") { btnDlQuestionSinglePage.Visible = true; btnDlQuestionMergedFiles.Visible = true; } else if (string.IsNullOrEmpty(hdn_IsActive.Value) || hdn_IsActive.Value == "0")//TODO else permision is false or null total new header { btnDlQuestionMergedFiles.Visible = true; } } } var answerSheetType = string.Empty; var rrr = (DataRowView)e.Item.DataItem; if (Convert.ToBoolean(rrr["AnswerSheet1"])) { answerSheetType += "پاسخگویی در برگه سوالات"; } if (Convert.ToBoolean(rrr["AnswerSheet2"])) { if (answerSheetType.Length > 0) { answerSheetType += " | "; } answerSheetType += " تشریحی "; } if (Convert.ToBoolean(rrr["AnswerSheet3"])) { if (answerSheetType.Length > 0) { answerSheetType += " | "; } answerSheetType += " تستی "; } e.Item.Cells[9].Text = answerSheetType; //TableCell cell = dataItem["did"]; string tt = (hdn_Pass.Value.ToString()); byte[] str = Convert.FromBase64String(tt); string pass = EncryptionClass.DecryptRJ256(str); lbl_Password.Text = pass; } }
protected void grd_Class_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "Filter") { return; } string did = "0"; var dtdet = new DataTable(); var path = string.Empty; var absPath = string.Empty; var pass = string.Empty; var hdnPassword = (HiddenField)e.Item.FindControl("hdnPassword"); if (e.CommandName == "ShowNewHeaderForAll" || e.CommandName == "ShowNewHeader" || e.CommandName == "ShowOldHeader") { did = e.CommandArgument.ToString(); dtdet = examBusiness.Get_ExamdetailbyDid(did); path = $"QueizPapers/{dtdet.Rows[0]["tterm"].ToString()}/{dtdet.Rows[0]["code_ostad"].ToString()}/pdffiles/{e.CommandArgument.ToString()}"; absPath = Server.MapPath($"~/{path}"); var base64HashesPassword = Convert.FromBase64String(hdnPassword.Value); pass = EncryptionClass.DecryptRJ256(base64HashesPassword); } var QuestionId = Convert.ToInt32(e.CommandArgument.ToString()); var constQuestionFileInfo = new ExamStudentDTO(); var whiteTape = Server.MapPath("~/University/Theme/images/whitePaper.jpg"); var questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg"); var userID = Session[sessionNames.userID_Karbar].ToString(); switch (e.CommandName) { case "ShowNewHeaderForAll": constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO() { TypeNimsal = x.Field <string>("typeNimsal"), CourseTitle = x.Field <string>("namedars"), ProfossorFullName = x.Field <string>("osname"), ExamDate = x.Field <string>("dateexam"), ExamTime = x.Field <string>("saatexam"), KeyCode = x.Field <string>("keyCode"), ExamDuration = x.Field <string>("examTime"), Calculator = x.Field <string>("calculator"), Note = x.Field <string>("note"), LowBook = x.Field <string>("LowBook"), ClassCode = x.Field <string>("ClassCode").ToString() }).FirstOrDefault(); var dt = examBusiness.ExamAnswerSheetbyDid(did, int.Parse(Session[sessionNames.userID_Karbar].ToString())); var studentList = dt.AsEnumerable().Select(x => new ExamStudentDTO() { FirstName = x.Field <string>("stFirstName"), LastName = x.Field <string>("stLastName"), StudentCode = x.Field <string>("stcode"), Grade = x.Field <string>("magh"), Major = x.Field <string>("nameresh"), SeatHeader = x.Field <string>("SeatHeader"), SeatNumber = x.Field <int?>("SeatNumber") }).ToList(); examBusiness.GeneratePdfQuestionForStudents(absPath, did.ToString(), pass, questioHeaderTemplate, whiteTape, userID, constQuestionFileInfo, studentList); Session["BigFile"] = true; ShowFiles($"{path}/{userID}/{did}_Momtahen_{userID}_2.zip", pass); break; case "ShowNewHeader": constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO() { TypeNimsal = x.Field <string>("typeNimsal"), CourseTitle = x.Field <string>("namedars"), ProfossorFullName = x.Field <string>("osname"), ExamDate = x.Field <string>("dateexam"), ExamTime = x.Field <string>("saatexam"), KeyCode = x.Field <string>("keyCode"), ExamDuration = x.Field <string>("examTime"), Calculator = x.Field <string>("calculator"), Note = x.Field <string>("note"), LowBook = x.Field <string>("LowBook"), ClassCode = x.Field <string>("ClassCode").ToString() }).FirstOrDefault(); examBusiness.ChangeTemplateOfQuestion(absPath, e.CommandArgument.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID); ShowFiles($"{path}/{userID}/{did}_Momtahen_{userID}_1.zip", pass); break; case "ShowOldHeader": constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO() { TypeNimsal = x.Field <string>("typeNimsal"), CourseTitle = x.Field <string>("namedars"), ProfossorFullName = x.Field <string>("osname"), ExamDate = x.Field <string>("dateexam"), ExamTime = x.Field <string>("saatexam"), KeyCode = x.Field <string>("keyCode"), ExamDuration = x.Field <string>("examTime"), Calculator = x.Field <string>("calculator"), Note = x.Field <string>("note"), LowBook = x.Field <string>("LowBook"), ClassCode = x.Field <string>("ClassCode").ToString() }).FirstOrDefault(); examBusiness.ChangeTemplateOfQuestion(absPath, e.CommandArgument.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID); ShowFiles($"{path}/{did}.zip", pass); break; case "ApproveNewHeader": examBusiness.SetApproveNewHeader(QuestionId, true); BindGrid = true; grd_Class.Rebind(); break; case "RejectNewHeader": examBusiness.SetApproveNewHeader(QuestionId, false); BindGrid = true; grd_Class.Rebind(); break; } }
protected void btnSaveQ_Att_Click(object sender, EventArgs e) { if (Page.IsValid) { if (fileUploader.HasFile) { string QExt = "pdf"; string AttExt = "jpg"; string fullPathQuestionFile = ""; string fullPathAttachFile = ""; string fullPathZipFile = ""; //helper class to transfer data to db var Q_Att_Dto = new ExamQuestionDto(); ViewState["Qs_Attach22"] = null; if (AttachUploader.HasFile) { AttExt = CommonBusiness.getFileExtension(AttachUploader.FileName).ToLower(); } if ((QExt != "pdf" && QExt != "jpg") || (AttExt != "pdf" && AttExt != "jpg")) { rwm.RadAlert("فرمت صحیح انتخاب گردد", null, 100, "خطا", ""); } else { int qId = int.Parse(Request.QueryString["qID"].ToString()); string did = Request.QueryString["did"].ToString(); string saatExam = Request.QueryString["examTime"].ToString(); string dateExam = Request.QueryString["examDate"].ToString(); int? cityIdQ2 = int.Parse(Request.QueryString["cityId"].ToString()); int statusQ2 = int.Parse(Request.QueryString["statusQ2"].ToString()); int statusQ1 = int.Parse(Request.QueryString["statusQ1"].ToString()); int?cityIDQ2 = null; if (statusQ1 == 3 && statusQ2 != -1) { cityIDQ2 = cityIdQ2; } var examQ = Ebusiness.GetExamQuestionsbyDid(did, null, cityIDQ2); if (examQ != null && bool.Parse(examQ.Rows[0]["TemplateDownloaded"].ToString()) == true) { var userID = Session[sessionNames.userID_StudentOstad].ToString(); //var questionID = examQ.AsEnumerable().Select(s => s.Field<int>("ID")).FirstOrDefault(); var relativePath = $"~/QueizPapers/{examQ.Rows[0]["Term"].ToString()}/{userID}/pdfFiles/{did.ToString()}"; string absolutePath = Server.MapPath(relativePath); byte[] hashPassword = Convert.FromBase64String(examQ.Rows[0]["Password"].ToString()); string filepass = EncryptionClass.DecryptRJ256(hashPassword); //string filepass = generaterandomstr(8); //اگر امتحان لغو کلی شده برای همه شهرها if (qId > 0 && (statusQ2 == 8 || statusQ2 == 11) && cityIdQ2 == -1) { fullPathZipFile = $"{absolutePath}/{did.ToString()}_canceled_1.zip"; //Q_Att_Dto.HashedPass = EncryptionClass.EncryptRJ(filepass); } //اگر امتحان لغو شده برای برای یه شهر خاص else if (qId > 0 && (statusQ2 == 8 || statusQ2 == 11) && cityIdQ2 > 0) { fullPathZipFile = $"{absolutePath}/{did.ToString()}_canceled_2.zip"; //Q_Att_Dto.HashedPass = EncryptionClass.EncryptRJ(filepass); } else { fullPathZipFile = $"{absolutePath}/{did.ToString()}.zip"; } //Directory.GetDirectories(absolutePath).ToList().ForEach(dir => Directory.Delete(dir, true)); //Directory.GetFiles(absolutePath, "*.*").ToList().ForEach(file => File.Delete(file)); if (fileUploader.HasFile)//آپلود سوالات { Q_Att_Dto.IsExistQuestionFile = true; Q_Att_Dto.Did = did.ToString(); Q_Att_Dto.QuestionId = qId.ToString(); //questionID.ToString(); Q_Att_Dto.UserId = userID; Q_Att_Dto.HashedPass = examQ.Rows[0]["Password"].ToString(); //EncryptionClass.EncryptRJ(filepass); Q_Att_Dto.RelativePath = relativePath; QExt = CommonBusiness.getFileExtension(fileUploader.FileName).ToLower(); if (!Directory.Exists(absolutePath)) { Directory.CreateDirectory(absolutePath); } fullPathQuestionFile = $"{absolutePath}/{did}.{QExt}"; if (QExt == "pdf" || QExt == "jpg") { //var file = fileUploader.PostedFile; var qfSaved = SaveFile(fileUploader.PostedFile, absolutePath, did + "." + QExt); if (!qfSaved) { rwm.RadAlert("خطا در روند بارگذاری فایل سوالات! لطفا مجدداً بارگذاری نمائید.", null, 100, "", ""); return; } using (ZipFile zip = new ZipFile()) { zip.Password = filepass; FileStream stream = null; using (stream = new FileStream(fullPathQuestionFile, FileMode.Open, FileAccess.ReadWrite)) { zip.AddEntry(did.ToString() + "." + QExt, stream); zip.Save(fullPathZipFile); } } } } if (AttachUploader.HasFile)//آپلود سوالت پیوست { Q_Att_Dto.IsExistAttachFile = true; AttExt = CommonBusiness.getFileExtension(AttachUploader.FileName).ToLower(); fullPathAttachFile = $"{absolutePath}/{did}Attached.{AttExt}"; if (AttExt == "jpg" || AttExt == "pdf") { Q_Att_Dto.AttExt = AttExt; var att_fSaved = SaveAttachFile(AttachUploader.PostedFile, absolutePath, did + "Attached." + AttExt); if (!att_fSaved) { rwm.RadAlert("خطا در روند بارگذاری فایل پیوست سوالات! لطفا مجدداً بارگذاری نمائید.", null, 100, "", ""); return; } using (ZipFile zip = new ZipFile(fullPathZipFile)) { zip.Password = filepass; FileStream stream = null; stream = new FileStream(fullPathAttachFile, FileMode.Open, FileAccess.ReadWrite); zip.AddEntry(did.ToString() + "Attached." + AttExt, stream); zip.Save(fullPathZipFile); } } } Directory.GetFiles(absolutePath, "*.*").Where(w => !w.Contains(".zip")).ToList().ForEach(file => File.Delete(file)); if (File.Exists(fullPathZipFile)) { var whiteTape = Server.MapPath("~/University/Theme/images/whitePaper.jpg"); var questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg"); var examQ_Detail = Ebusiness.Get_ExamdetailbyDid(did, null, cityIDQ2);//.AsEnumerable().Select(s=>s).FirstOrDefault(); var constQuestionFileInfo = new ExamStudentDTO(); constQuestionFileInfo.TypeNimsal = examQ_Detail.Rows[0]["typeNimsal"].ToString(); constQuestionFileInfo.CourseTitle = examQ_Detail.Rows[0]["namedars"].ToString(); constQuestionFileInfo.ProfossorFullName = examQ_Detail.Rows[0]["osname"].ToString(); constQuestionFileInfo.ExamDate = examQ_Detail.Rows[0]["dateexam"].ToString(); constQuestionFileInfo.ExamTime = examQ_Detail.Rows[0]["saatexam"].ToString(); constQuestionFileInfo.KeyCode = examQ_Detail.Rows[0]["keyCode"].ToString(); constQuestionFileInfo.ExamDuration = examQ_Detail.Rows[0]["examTime"].ToString(); constQuestionFileInfo.Calculator = examQ_Detail.Rows[0]["calculator"].ToString(); constQuestionFileInfo.Note = examQ_Detail.Rows[0]["note"].ToString(); constQuestionFileInfo.LowBook = examQ_Detail.Rows[0]["LowBook"].ToString(); constQuestionFileInfo.ClassCode = examQ_Detail.Rows[0]["ClassCode"].ToString(); constQuestionFileInfo.Grade = examQ_Detail.Rows[0]["magh"].ToString(); constQuestionFileInfo.Major = examQ_Detail.Rows[0]["nameresh"].ToString(); Ebusiness.ChangeTemplateOfQuestion(absolutePath, did, filepass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID, cityIDQ2); var lastPdfPath = $"{Request.Url.GetLeftPart(UriPartial.Authority)}/{relativePath.Replace("~/", "")}/{userID}/{did}_Momtahen_{userID}_1.pdf?ts={DateTime.Now.Ticks}"; PdfFileSource = lastPdfPath; ViewState["Qs_Attach22"] = Q_Att_Dto; SectionManagement(false, false, true); } else { rwm.RadAlert("هیچ فایلی ارسال نشده است. لطفا مجددا فایل خود را ارسال نمایید", null, 100, "", ""); } } else { rwm.RadAlert("ابتدا فرم سوالات دانلود شود", null, 100, "خطا", ""); } } } else { rwm.RadAlert("فایل سوالات انتخاب شود ", null, 100, "خطا", ""); } } }
protected void grdResult_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { switch (e.CommandName) { case "OpenQuestion": case "OpenAttachment": var examQuestion = eBusiness.GetExamQuestionById(Convert.ToInt32(e.CommandArgument)); if (examQuestion.Rows.Count > 0) { string questionsFile = ""; byte[] fileByteArray; string _filName = ""; string base64EncodedPDF = ""; var nocash = DateTime.Now.ToString("yyyyMMddHHmmssFFF"); var zipfilePath = examQuestion.Rows[0]["Address"].ToString(); zipfilePath = zipfilePath.Replace("..", "~"); var dynamicPath = zipfilePath.Substring(0, zipfilePath.LastIndexOf('/')); var path = Server.MapPath(dynamicPath); var filesInDir = Directory.GetFiles(path, "*.*"); var flg = DeleteImedatellyFiles(path); if (!File.Exists(Server.MapPath(zipfilePath))) { var p = path.Replace("\\", " ==> "); var str = string.Format("فایلی جهت نمایش در مسیر{0} یافت نشد", path); rwm.RadAlert(str, null, 100, "پیام", ""); return; } ZipFile zip = ZipFile.Read(Server.MapPath(zipfilePath)); zip.Password = EncryptionClass.DecryptRJ256(Convert.FromBase64String(examQuestion.Rows[0]["Password"].ToString())); zip.ExtractAll(path.ToString(), ExtractExistingFileAction.OverwriteSilently); zip.Dispose(); filesInDir = Directory.GetFiles(path, "*.*"); string ext = ""; if (e.CommandName == "OpenQuestion") { var extsPath = filesInDir.Where(w => !w.Contains("Attached") && !w.Contains("zip")).FirstOrDefault()?.ToString(); if (extsPath == null) { return; } ext = String.Join("", extsPath).Split('\\').Last().Split('.')[1]; if (!string.IsNullOrEmpty(ext)) { ext = "." + ext; questionsFile = dynamicPath + "/" + examQuestion.Rows[0]["did"].ToString() + ext; //?q=" + nocash; _filName = Server.MapPath(questionsFile); fileByteArray = System.IO.File.ReadAllBytes(_filName); base64EncodedPDF = System.Convert.ToBase64String(fileByteArray); Session["pdfPath"] = fileByteArray; var c_type = GetMimeType(ext); Session["contentType"] = c_type; } else { return; } } else { var extsPath = filesInDir.Where(w => w.Contains("Attached")).FirstOrDefault()?.ToString(); if (extsPath == null) { return; } ext = String.Join("", extsPath).Split('\\').Last().Split('.')[1]; if (!string.IsNullOrEmpty(ext)) { ext = "." + ext; questionsFile = dynamicPath + "/" + examQuestion.Rows[0]["did"].ToString() + "Attached" + ext; //?q=" + nocash; _filName = Server.MapPath(questionsFile); fileByteArray = System.IO.File.ReadAllBytes(_filName); base64EncodedPDF = System.Convert.ToBase64String(fileByteArray); Session["pdfPath"] = fileByteArray; var c_type = GetMimeType(ext); Session["contentType"] = c_type; } else { return; } } DeleteImedatellyFiles(path); var clientFunction = "openShowFileInPopup('ShowFilePrevious.aspx?q=" + nocash + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", clientFunction, true); } break; } }