Ejemplo n.º 1
0
        public void DeleteFolder(string organizationId, string folder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            string rootPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                organizationId, folder);

            DirectoryInfo treeRoot = new DirectoryInfo(rootPath);

            if (treeRoot.Exists)
            {
                DirectoryInfo[] dirs = treeRoot.GetDirectories();
                while (dirs.Length > 0)
                {
                    foreach (DirectoryInfo dir in dirs)
                        DeleteFolder(organizationId,
                            folder != string.Empty ? string.Format("{0}\\{1}", folder, dir.Name) : dir.Name,
                            webDavSetting);

                    dirs = treeRoot.GetDirectories();
                }

                // DELETE THE FILES UNDER THE CURRENT ROOT
                string[] files = Directory.GetFiles(treeRoot.FullName);
                foreach (string file in files)
                {
                    File.SetAttributes(file, FileAttributes.Normal);
                    File.Delete(file);
                }

                IWebDav webdav = new WebDav(webDavSetting);

                webdav.DeleteAllWebDavRules(organizationId, folder);

                Directory.Delete(treeRoot.FullName, true);
            }
        }
Ejemplo n.º 2
0
        public SystemFile RenameFolder(string organizationId, string originalFolder, string newFolder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            var oldPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                organizationId, originalFolder);
            var newPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                organizationId, newFolder);

            FileUtils.MoveFile(oldPath, newPath);

            IWebDav webdav = new WebDav(webDavSetting);

            //deleting old folder rules
            webdav.DeleteAllWebDavRules(organizationId, originalFolder);

            return GetFolder(organizationId, newFolder, webDavSetting);
        }