protected void btnSave_Click(object sender, EventArgs e) { if (ddlDepartment.SelectedValue != "--Select--") { string sPath = System.Configuration.ConfigurationManager.AppSettings["OCA_Folder_NAME"].ToString(); if (HttpContext.Current.Session["Operation"] == null) { if (HttpContext.Current.Session["Filename"] != null) { string savePath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["Info_Path"].ToString()); string fileName = Session["Filename"].ToString(); FileInfo fi = new FileInfo(savePath + fileName); double size = fi.Length; string folderid = ddlDepartment.SelectedValue; string fun = null; DataTable dt = objCP.Insert_UploadFiles(Session["OriginalFile"].ToString(), Session["extension"].ToString().Replace(".", ""), size, Convert.ToInt32(GetSessionUserID()), folderid, txtTitle.Text, txtContent.Text, Session["Charter_ID"].ToString(), "ADD", fun); string res = dt.Rows[0]["File_Id"].ToString(); // string res = Session["res"].ToString(); string F1 = Mid(res, 0, 2); string F2 = Mid(res, 2, 2); string F3 = Mid(res, 4, 2); if (!Directory.Exists(savePath + F1 + "\\" + F2 + "\\" + F3)) { Directory.CreateDirectory(savePath + F1 + "\\" + F2 + "\\" + F3); } File.Move(savePath + fileName, savePath + F1 + "\\" + F2 + "\\" + F3 + "\\" + res + Session["extension"].ToString()); if (!Directory.Exists(sPath + "\\" + F1 + "\\" + F2 + "\\" + F3)) { Directory.CreateDirectory(sPath + "\\" + F1 + "\\" + F2 + "\\" + F3); } File.Move(sPath + "\\" + Session["Filename"], sPath + "\\" + F1 + "\\" + F2 + "\\" + F3 + "\\" + res + Session["extension"].ToString()); Session["Filename"] = null; BindAttachment(); txtContent.Text = ""; txtTitle.Text = ""; ddlDepartment.SelectedIndex = 0; Session["Operation"] = null; string hidemodal = String.Format("hideModal('dvAddFolder')"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true); } else { string showmodal = String.Format(" showModal('dvAddFolder', true, dvAddFolder_onClose);"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", showmodal, true); } } else { objCP.Insert_UploadFiles(null, null, null, Convert.ToInt32(GetSessionUserID()), ddlDepartment.SelectedValue, txtTitle.Text, txtContent.Text, Session["Charter_ID"].ToString(), "EDIT", Session["arg"].ToString()); BindAttachment(); txtContent.Text = ""; txtTitle.Text = ""; Session["Operation"] = null; string hidemodal = String.Format("hideModal('dvAddFolder')"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true); } } else { string showmodal = String.Format(" showModal('dvAddFolder', true, dvAddFolder_onClose);"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", showmodal, true); } }