Exemple #1
0
        public override string CreateDirectory(string path, string name)
        {
            try
            {
                var directoryName = name.Trim();
                var virtualPath   = FileSystemValidation.ToVirtualPath(path);

                var returnValue = DNNValidator.OnCreateFolder(virtualPath, directoryName);
                if (!(string.IsNullOrEmpty(returnValue)))
                {
                    return(returnValue);
                }

                //Returns errors or empty string when successful (ie: DirectoryAlreadyExists, InvalidCharactersInPath)
                returnValue = TelerikContent.CreateDirectory(virtualPath, directoryName);

                if (!(string.IsNullOrEmpty(returnValue)))
                {
                    return(GetTelerikMessage(returnValue));
                }

                if (string.IsNullOrEmpty(returnValue))
                {
                    var virtualNewPath = FileSystemValidation.CombineVirtualPath(virtualPath, directoryName);
                    var newFolderID    = DNNFolderCtrl.AddFolder(PortalSettings.PortalId, FileSystemValidation.ToDBPath(virtualNewPath));
                    FileSystemUtils.SetFolderPermissions(PortalSettings.PortalId, newFolderID, FileSystemValidation.ToDBPath(virtualNewPath));
                    //make sure that the folder is flagged secure if necessary
                    DNNValidator.OnFolderCreated(virtualNewPath, virtualPath);
                }

                return(returnValue);
            }
            catch (Exception ex)
            {
                return(DNNValidator.LogUnknownError(ex, path, name));
            }
        }