예제 #1
0
        protected bool DeleteFiles(string FolderName, string Version)
        {
            bool WasSuccessful = true;

            string strListFile = Path.Combine(Path.Combine(InstallerInfo.SitePath, Path.Combine("DesktopModules", FolderName)), Version + ".txt");

            if (File.Exists(strListFile))
            {
                // read list file
                StreamReader objStreamReader;
                objStreamReader = File.OpenText(strListFile);
                Array arrPaths = objStreamReader.ReadToEnd().Split(ControlChars.CrLf.ToCharArray());
                objStreamReader.Close();

                // loop through path list
                string strPath;

                foreach (string tempLoopVar_strPath in arrPaths)
                {
                    strPath = tempLoopVar_strPath;
                    if (strPath.Trim() != "")
                    {
                        strPath = Common.Globals.ApplicationMapPath + "\\" + strPath;
                        if (strPath.EndsWith("\\"))
                        {
                            // folder
                            if (Directory.Exists(strPath))
                            {
                                try // delete the folder
                                {
                                    Globals.DeleteFolderRecursive(strPath);
                                }
                                catch (Exception)
                                {
                                    // supress
                                }
                            }
                        }
                        else
                        {
                            // file
                            if (File.Exists(strPath))
                            {
                                try // delete the file
                                {
                                    File.SetAttributes(strPath, FileAttributes.Normal);
                                    File.Delete(strPath);
                                }
                                catch (Exception)
                                {
                                    // suppress
                                }
                            }
                        }
                    }
                }
            }

            return(WasSuccessful);
        }
예제 #2
0
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            string strSkinPath      = Globals.ApplicationMapPath.ToLower() + cboSkins.SelectedItem.Value;
            string strContainerPath = Globals.ApplicationMapPath.ToLower() + cboContainers.SelectedItem.Value;

            if (UserInfo.IsSuperUser == false && cboSkins.SelectedItem.Value.IndexOf("\\portals\\_default\\", 0) != -1)
            {
                string strMessage = Localization.GetString("SkinDeleteFailure", this.LocalResourceFile);
                UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessageType.RedError);
            }
            else
            {
                if (cboSkins.SelectedIndex > 0)
                {
                    if (Directory.Exists(strSkinPath))
                    {
                        Globals.DeleteFolderRecursive(strSkinPath);
                    }
                    if (Directory.Exists(strSkinPath.Replace("\\" + SkinInfo.RootSkin.ToLower() + "\\", "\\" + SkinInfo.RootContainer + "\\")))
                    {
                        Globals.DeleteFolderRecursive(strSkinPath.Replace("\\" + SkinInfo.RootSkin.ToLower() + "\\", "\\" + SkinInfo.RootContainer + "\\"));
                    }
                }

                if (cboContainers.SelectedIndex > 0)
                {
                    if (Directory.Exists(strContainerPath))
                    {
                        Globals.DeleteFolderRecursive(strContainerPath);
                    }
                }
            }

            LoadSkins();
            LoadContainers();

            ShowSkins();
            ShowContainers();
        }