public static void TemplateDataBind(string Module, DropDownList ddlTemplate, int PortalId, string LocalResourceFile, HttpServerUtility Server)
 {
     ddlTemplate.Items.Clear();
     ddlTemplate.Items.Add(new ListItem(Localization.GetString("selectTemplate", LocalResourceFile), ""));
     for (int type = 1; type < 4; type++)
     {
         string path = TemplateEditorUtils.GenerateDirectory(Module, type, "", PortalId, Server);
         if (!string.IsNullOrEmpty(path) && Directory.Exists(Server.MapPath(path)))
         {
             var dryLst = Directory.GetDirectories(Server.MapPath(path));
             if (dryLst.Count() > 0 && (Directory.GetFiles(Server.MapPath(path)).Count() == 0 || Module == "Blog"))
             {
                 foreach (string item in dryLst)
                 {
                     int nb = item.LastIndexOf('\\');
                     ddlTemplate.Items.Add(new ListItem(GetTypes()[type] + " - " + item.Substring(nb + 1), ReverseMapPath(item)));
                 }
             }
             else
             {
                 ddlTemplate.Items.Add(new ListItem(GetTypes()[type], path));
             }
         }
     }
     if (ddlTemplate.Items.Count == 2)
     {
         ddlTemplate.Items.RemoveAt(0);
         ddlTemplate.SelectedIndex = 0;
     }
 }
        private void UnzipFile(HttpPostedFile objFileUpload)
        {
            ZipInputStream s = new ZipInputStream(objFileUpload.InputStream);
            ZipEntry       theEntry;
            string         virtualPath   = "~" + TemplateEditorUtils.GenerateDirectory(ddlModule, ddlType, tbxNewTemplate, PortalId, Server) + "/";
            string         fileName      = string.Empty;
            string         folderName    = string.Empty;
            string         fileExtension = string.Empty;
            string         fileSize      = string.Empty;

            while ((theEntry = s.GetNextEntry()) != null)
            {
                folderName    = Path.GetDirectoryName(theEntry.Name);
                fileName      = Path.GetFileName(theEntry.Name);
                fileExtension = Path.GetExtension(fileName);

                if (!string.IsNullOrEmpty(fileName))
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(folderName))
                        {
                            Directory.CreateDirectory(Server.MapPath(virtualPath + folderName));
                        }

                        FileStream streamWriter = File.Create(Server.MapPath(virtualPath + folderName + "/" + fileName));
                        int        size         = 2048;
                        byte[]     data         = new byte[2048];

                        do
                        {
                            size = s.Read(data, 0, data.Length);
                            streamWriter.Write(data, 0, size);
                        } while (size > 0);

                        fileSize = Convert.ToDecimal(streamWriter.Length / 1024).ToString() + " KB";

                        streamWriter.Close();
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.ToString());
                    }
                }
            }
            s.Close();
        }
        protected void btnValid_Click(object sender, EventArgs e)
        {
            if (Request.Cookies["lkbRefresh"] != null)
            {
                HttpCookie myCookie = new HttpCookie("lkbRefresh");
                myCookie.Expires = DateTime.Now.AddDays(-1d);
                Response.Cookies.Add(myCookie);
            }
            Response.Cookies["ddlModule"].Value = ddlModule.SelectedValue;
            //Response.Cookies["ddlType"].Value = ddlType.SelectedValue;
            //Response.Cookies["ddlTemplate"].Value = tbxNewTemplate.Text;
            string newpath = TemplateEditorUtils.GenerateDirectory(ddlModule.SelectedValue, int.Parse(ddlType.SelectedValue), tbxNewTemplate.Text, PortalId, Server, false);

            Response.Cookies["ddlTemplate"].Value = newpath;
            newpath = Server.MapPath(newpath);
            Directory.CreateDirectory(newpath);

            if (rblMode.SelectedValue == "0")
            {
                Response.Redirect(Globals.NavigateURL(), true);
            }
            else if (rblMode.SelectedValue == "1")
            {
                string copypath = Server.MapPath(TemplateEditorUtils.GenerateDirectory(ddlModule, ddlTypeCopy, ddlTemplate, PortalId, Server));
                CopyDirectoriesAndFiles(copypath, newpath);
                Response.Redirect(Globals.NavigateURL(), true);
            }
            else if (rblMode.SelectedValue == "2" && updZip.HasFile)
            {
                UnzipFile(updZip.PostedFile);
                Response.Redirect(Globals.NavigateURL(), true);
            }
            else
            {
                //lblMode.Text = Localization.GetString("lblModeZip", LocalResourceFile);
                //lblMode.HelpText = Localization.GetString("lblModeZip.Help", LocalResourceFile);

                lblemptyFile.Visible = true;
                lblemptyFile.Text    = Localization.GetString("emptyFile", LocalResourceFile);
            }
        }
    public static void TemplateDataBind(string Module, int Type, DropDownList ddlTemplate, int PortalId, string LocalResourceFile, HttpServerUtility Server)
    {
        if (Type > 0)
        {
            ddlTemplate.Items.Clear();
            ddlTemplate.Items.Add(new ListItem(Localization.GetString("selectTemplate", LocalResourceFile), ""));
            string path = TemplateEditorUtils.GenerateDirectory(Module, Type, ddlTemplate.SelectedValue, PortalId, Server);
            if (!string.IsNullOrEmpty(path) && Directory.Exists(Server.MapPath(path)))
            {
                var dryLst = Directory.GetDirectories(Server.MapPath(path));

                foreach (string item in dryLst)
                {
                    int nb = item.LastIndexOf('\\');
                    ddlTemplate.Items.Add(item.Substring(nb + 1));
                }
            }
        }
        else
        {
            ddlTemplate.Items.Clear();
            ddlTemplate.Items.Add(new ListItem(Localization.GetString("selectTemplate", LocalResourceFile), ""));
        }
    }