Example #1
0
            // Show directories as album name instead of pin.
            public override DirectoryItem ResolveRootDirectoryAsTree(string path)
            {
                Album album = new Album();

                try
                {
                    DirectoryItem orgDir = base.ResolveRootDirectoryAsTree(path);

                    string pin         = "";
                    int    firstSlash  = GetNthIndex(path, '/', 3);
                    int    secondSlash = GetNthIndex(path, '/', 4);
                    if (secondSlash > firstSlash)
                    {
                        pin = path.Substring(firstSlash, (secondSlash - firstSlash)) + " : ";
                    }
                    else
                    {
                        pin = orgDir.Name + " : ";
                    }


                    orgDir.Name = pin + album.GetAlbumName(orgDir.Name);
                    return(orgDir);
                }
                catch (UnauthorizedAccessException)
                {
                    //Eat access exceptions.
                    //return new DirectoryItem();
                    return(null);
                }
            }
Example #2
0
 private DirectoryItem[] GetChildDirectories(string path)
 {
     //DirectoryItem[] directories;
     //if (IsChildOf(path, ExtractPath(SelectedUrl)))
     //{
     //    DataRow[] childRows = DataServer.GetChildDirectoryRows(path);
     //    directories = new DirectoryItem[childRows.Length];
     //    int i = 0;
     //    while (i < childRows.Length)
     //    {
     //        DataRow childRow = childRows[i];
     //        string name = childRow["Name"].ToString();
     //        string itemFullPath = EndWithSlash(CombinePath(path, name));
     //        directories[i] =
     //            new DirectoryItem(name, string.Empty, itemFullPath, itemFullPath, fullPermissions, GetChildFiles(itemFullPath),
     //                              GetChildDirectories(itemFullPath));
     //        i = i + 1;
     //    }
     //    return directories;
     //}
     if (path == "/")
     {
         DirectoryItem[] directories = new DirectoryItem[2];
         directories[0] = new DirectoryItem("User", string.Empty, "/User", string.Empty, fullPermissions,
                                            GetChildFiles("/User"), new DirectoryItem[0]);
         directories[1] = new DirectoryItem("Knowledge", string.Empty, "/Knowledge", string.Empty, fullPermissions,
                                            GetChildFiles("/Knowledge"), new DirectoryItem[0]);
         return(directories);
     }
     return(new DirectoryItem[] { });
 }
Example #3
0
            public List<Item> GetItems(string path)
            {
                var items = new List<Item>();
                var dirInfo = new DirectoryInfo(path);
                foreach (var dir in dirInfo.GetDirectories())
                {
                    var item = new DirectoryItem
                    {
                        Name = dir.Name,
                        Path = dir.FullName,
                        Items = GetItems(dir.FullName)
                    };
                    items.Add(item);
                }

                foreach (var file in dirInfo.GetFiles())
                {
                    var item = new FileItem
                    {
                        Name = file.Name,
                        Path = file.FullName
                    };
                    items.Add(item);
                }

                return items;
            }
        public void Export(DirectoryItem rootNode, string fullyQualifiedFilepath, StringBuilder sb)
        {
            sb.AppendLine(rootNode.ItemName);

            foreach (DirectoryItem node in rootNode.Items)
            {
                if (string.IsNullOrWhiteSpace(node.Checksum))
                {
                    sb.AppendLine($"|\t{node.ItemName}");
                }
                else
                {
                    sb.AppendLine($"|\t{node.ItemName}  : {node.Checksum}");
                }

                if (node.HasChildren)
                {
                    ExportNode(sb, node);
                }
            }

            using (StreamWriter writer = new StreamWriter(fullyQualifiedFilepath))
            {
                writer.Write(sb.ToString());
                writer.Flush();
            }
        }
Example #5
0
        /// <summary>
        /// Explores a subfolder in the current directory and adds it to the address bar
        /// </summary>
        /// <param name="dir">The directory to advance in</param>
        public void Explore(DirectoryItem dir)
        {
            AddAddressButton(dir);
            CurrentPath = dir.Path;

            Explore(dir.Items);
        }
Example #6
0
        public List <TreeViewItems> GetItems(string path)
        {
            var items = new List <TreeViewItems>();


            var dirInfo = new DirectoryInfo(path);

            foreach (var directory in dirInfo.GetDirectories())
            {
                var item = new DirectoryItem
                {
                    Name  = directory.Name,
                    Items = GetItems(directory.FullName)
                };

                items.Add(item);
            }

            foreach (var file in dirInfo.GetFiles())
            {
                var item = new FileItem
                {
                    Name = file.Name,
                };

                items.Add(item);
            }

            return(items);
        }
        public DirectoryItem SetCurrentDirectory(string directoryName)
        {
            // The following is a useful algorithm for iterating through a hierarchical
            // tree structure without recursion.

            // Need to be able to iterate and search through the existing composite
            //Iterative stack based solution
            var directoryStack = new Stack <DirectoryItem>();

            // Sets the stack at the root of the composite
            directoryStack.Push(RootDirectory);

            while (directoryStack.Any())
            {
                var current = directoryStack.Pop();
                // Is this the directory we are searching for?
                if (current.Name == directoryName)
                {
                    // Yes, then set current directory and exit
                    _currentDirectory = current;
                    return(current);
                }
                // Push child directory items onto the stack for search also on next loop iteration
                // Focus on directory items only
                foreach (var item in current.Items.OfType <DirectoryItem>())
                {
                    directoryStack.Push(item);
                }
            }
            throw new InvalidOperationException($"Directory name {directoryName} not found.");
        }
Example #8
0
        public CollectionOfIItem GetItems(string path)
        {
            var items = new CollectionOfIItem();

            var dirInfo = new DirectoryInfo(path);

            foreach (var directory in dirInfo.GetDirectories())
            {
                var item = new DirectoryItem
                {
                    Name      = directory.Name,
                    ContentID = directory.FullName,
                    Items     = GetItems(directory.FullName)
                };

                items.Add(item);
            }

            foreach (var file in dirInfo.GetFiles())
            {
                var item = new FileItem
                {
                    Name      = file.Name,
                    ContentID = file.FullName
                };

                items.Add(item);
            }

            return(items);
        }
Example #9
0
        /* Create DirectoryInfo instances for each subdirectory in the current directory */
        private List <DirectoryItem> GetSubDirectories(DirectoryItem directory)
        {
            DirectoryInfo dirInfo;
            var           subdirs = new List <DirectoryItem>();

            logger.Trace("Getting subdirectory list for directory: {0}", directory.Path);

            try
            {
                dirInfo = new DirectoryInfo(directory.Path);
                foreach (DirectoryInfo subDirInfo in dirInfo.GetDirectories())
                {
                    logger.Trace("Discovered subdirectory: {0}", subDirInfo.FullName);
                    subdirs.Add(new DirectoryItem(subDirInfo.FullName));
                }
            }
            catch (Exception ex)
            {
                logger.Info(
                    ex,
                    "Subdirectory list could not be obtained for {0}",
                    directory.Path);
            }

            return(subdirs);
        }
Example #10
0
        private void SendFolder(DirectoryItem folder, string relativePath)
        {
            if (!folder.IsFolder)
            {
                throw new FailedSendingException("Cannot send file as folder.");
            }


            // Send folder info
            byte[] infoBuffer = new byte[1 + 8 + 1024];
            infoBuffer[0] = (byte)TTInstruction.Transfer_FolderInfo;

            string fullName = $"{relativePath}{folder.Name}";

            byte[] fullNameBytes = Encoding.UTF8.GetBytes(fullName);
            Array.Copy(fullNameBytes, 0, infoBuffer, 1 + 8, fullNameBytes.Length);

            TrySend(infoBuffer, true);


            // Send contents
            fullName += "\\";
            DirectoryItem[] contents = folder.GetChildren();
            foreach (var c in contents)
            {
                if (c.IsFolder)
                {
                    SendFolder(c, fullName);
                }
                else
                {
                    SendFile(c, fullName);
                }
            }
        }
Example #11
0
        public async static Task getSystemVersions(cServer ShareServer)
        {
            if (XMLSystemState == null)
            {
                using (var ftp = new cFTP(ShareServer, "APPS_CS"))
                {
                    var Item = new DirectoryItem()
                    {
                        Server      = ShareServer,
                        IsDirectory = false,
                        Name        = "systems.xml",
                        BaseUri     = new UriBuilder("ftp://" + ShareServer.IP.ToString() + "/APPS_CS").Uri
                    };
                    try
                    {
                        await ftp.DownloadItemAsync(Item, LOCAL_PATH + "systems.xml");
                    } catch (Exception ex)
                    {
                        //debugBox.AppendText(ex.Message);
                    }

                    XMLSystemState = XDocument.Load(LOCAL_PATH + "systems.xml");
                }
            }
        }
Example #12
0
            private void ProcessDirectory(DirectoryItem parent, string parentPath, DirectoryEntry entry)
            {
                DirectoryCount++;
                DirectoryItem newParent;
                string        newPath;

                if (parent == null)
                {
                    RootDirectory = new TreeStats.DirectoryItem();
                    newParent     = RootDirectory;
                    newPath       = parentPath;
                }
                else
                {
                    var newDir = new DirectoryItem {
                        Name = entry.Name
                    };
                    parent.Children.Add(newDir);
                    newParent = newDir;
                    newPath   = Path.Combine(parentPath, entry.Name);
                }
                foreach (var x in entry.Entries)
                {
                    ProcessTree(newParent, newPath, x);
                }
            }
Example #13
0
        public List <Item> GetItems(string path)
        {
            var items = new List <Item>();

            var dirInfo = new DirectoryInfo(path);

            foreach (var directory in dirInfo.GetDirectories())
            {
                var item = new DirectoryItem
                {
                    Name  = directory.Name,
                    Path  = directory.FullName,
                    Items = GetItems(directory.FullName)
                };

                items.Add(item);
            }

            foreach (var file in dirInfo.GetFiles().Where(f => f.Extension == ".rtf" || f.Extension == ".docx"))
            {
                var item = new FileItem
                {
                    Name = file.Name,
                    Path = file.FullName
                };

                items.Add(item);
            }

            return(items);
        }
Example #14
0
        /// <summary>
        /// Скачать папку с сервера
        /// </summary>
        /// <param name="dir">Экземпляр папки DirectoryItem.</param>
        /// <param name="localPath">Локальный путь к папке загрузки (без имени скачиваемой папки).</param>
        internal async Task <int> DownloadDirectoryAsync(DirectoryItem dir, string localPath)
        {
            int errors = 0;

            localPath += $"\\{dir.Name}";
            if (!Directory.Exists(localPath))
            {
                Directory.CreateDirectory(localPath);
            }
            List <DirectoryItem> dirItems = await webDavCore.ListAsync(dir.Uri);

            foreach (DirectoryItem dirItem in dirItems)
            {
                if (dirItem.IsFolder == true)
                {
                    errors += await DownloadDirectoryAsync(dirItem, localPath);
                }
                else
                {
                    if (!await DownloadFileAsync(dirItem, localPath))
                    {
                        errors++;
                    }
                }
            }
            return(errors);
        }
Example #15
0
    private DirectoryItem CreateDirectoryItem(DataRow item, bool includeSubfolders)
    {
        DirectoryItem directory = new DirectoryItem(item["Name"].ToString(),
                                                    this.GetLoaction(item),
                                                    this.GetFullPath(item),
                                                    String.Empty,
                                                    PathPermissions.Read,                                                     //correct permissions should be applied from the content provider
                                                    null,
                                                    null
                                                    );

        if (includeSubfolders)
        {
            DataRow[]            subDirItems = GetChildDirectories(item);
            List <DirectoryItem> subDirs     = new List <DirectoryItem>();

            foreach (DataRow subDir in subDirItems)
            {
                subDirs.Add(CreateDirectoryItem(subDir, false));
            }

            directory.Directories = subDirs.ToArray();
        }

        return(directory);
    }
Example #16
0
        private async Task <bool> IsNeedUpload(FileInfo fileInfo, string dirPath)
        {
            if (stopSync)
            {
                return(false);
            }

            LogController.Info(logger, $"Проверка файла {fileInfo.Name}...");

            string filePath = dirPath + $"/{fileInfo.Name}";

            if (!await webDavCore.ExistsAsync(filePath))
            {
                return(true);
            }

            DirectoryItem serverItem = await webDavCore.GetItemAsync(filePath);

            if (serverItem.LastModified < fileInfo.LastWriteTime)
            {
                return(true);
            }

            return(false);
        }
Example #17
0
        public static void getItemDateTime(DirectoryItem d)
        {
            DateTime DateValue;
            var      _path = d.AbsolutePath;

            if (d.IsDirectory)
            {
                _path += "/.";
            }
            FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(_path);

            Request.Credentials = new NetworkCredential(d.Server.User, d.Server.Password);
            Request.Method      = WebRequestMethods.Ftp.GetDateTimestamp;
            Request.UseBinary   = false;
            Request.Proxy       = null;

            using (FtpWebResponse Response = (FtpWebResponse)Request.GetResponse())
            {
                using (TextReader Reader = new StringReader(Response.StatusDescription))
                {
                    string DateString = Reader.ReadLine().Substring(4);
                    DateValue = DateTime.ParseExact(DateString, "yyyyMMddHHmmss", CultureInfo.InvariantCulture.DateTimeFormat);
                }
            }
            d.DateCreated = DateValue;
        }
Example #18
0
        public async Task DownloadItemAsync(DirectoryItem item, string localPath)
        {
            using (WebClient ftpClient = new MiWebClient())
            {
                ftpClient.Credentials = new NetworkCredential(server.User, server.Password);
                ftpClient.Proxy       = null;
                var _path = Path.GetDirectoryName(localPath);
                if (!Directory.Exists(_path))
                {
                    Directory.CreateDirectory(_path);
                }
                try
                {
                    await ftpClient.DownloadFileTaskAsync(item.Uri, localPath);

                    if (item.DateCreated != DateTime.Parse("01/01/0001 0:00:00"))
                    {
                        File.SetLastWriteTime(localPath, item.DateCreated);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                //await ftpClient.DownloadFileTaskAsync(item.Uri, @localPath);
            }
        }
Example #19
0
                /**
                 * @see https://msdn.microsoft.com/en-us/library/system.windows.data.imultivalueconverter.convert(v=vs.110).aspx
                 */
                public object Convert(object[] value, Type target_type, object parameter, CultureInfo culture)
                {
                    DirectoryItem directory = value[0] as DirectoryItem;
                    Dictionary <string, AssetList> mapping = value[1] as Dictionary <string, AssetList>;

                    return(directory != null && mapping.ContainsKey(directory.path.ToLower()) ? mapping[directory.path.ToLower()] : null);
                }
Example #20
0
        private void buttonDownload_Click(object sender, EventArgs e)
        {
            DirectoryItem item = (DirectoryItem)treeView.SelectedNode.Tag;

            if (item.IsDirectory)
            {
                return;
            }
            string path = GetPathOfNode(treeView.SelectedNode);

            saveFileDialog.FileName = item.Name;
            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Stream     stream   = conn.ReadFile(bucket, path);
            FileStream saveFile = File.Open(saveFileDialog.FileName, FileMode.Create, FileAccess.Write);

            // Is there a better way to do this? (pipe data from one stream into another)
            byte[] buffer    = new byte[1024];
            int    bytesRead = 0;

            while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
            {
                saveFile.Write(buffer, 0, bytesRead);
            }
            saveFile.Close();
            stream.Close();
        }
        private static void Traverse(string directory, DirectoryItem directoryItem)
        {
            foreach (var filePath in System.IO.Directory.GetFiles(directory))
            {
                var fileInfo = new FileInfo(filePath);
                directoryItem.Files.Add(new FileItem
                {
                    IsHidden = fileInfo.Attributes.HasFlag(FileAttributes.Hidden),
                    IsReadOnly = fileInfo.Attributes.HasFlag(FileAttributes.ReadOnly),
                    LastModified = fileInfo.LastWriteTime,
                    Name = fileInfo.Name,
                    Size = fileInfo.Length
                });
            }

            foreach (var directoryPath in System.IO.Directory.GetDirectories(directory))
            {
                var directoryInfo = new DirectoryInfo(directoryPath);
                var subDirectoryItem = new DirectoryItem
                {
                    IsHidden = directoryInfo.Attributes.HasFlag(FileAttributes.Hidden),
                    IsReadOnly = directoryInfo.Attributes.HasFlag(FileAttributes.ReadOnly),
                    LastModified = directoryInfo.LastWriteTime,
                    Name = directoryInfo.Name
                };
                directoryItem.Directories.Add(subDirectoryItem);
                Traverse(Path.Combine(directory, directoryInfo.Name), subDirectoryItem);
            }
        }
Example #22
0
        private void buttonUpload_Click(object sender, EventArgs e)
        {
            openFileDialog.Title           = "Choose a file to upload...";
            openFileDialog.FileName        = "";
            openFileDialog.CheckFileExists = true;
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            FileInfo fileInfo = new FileInfo(openFileDialog.FileName);

            DirectoryItem item = (DirectoryItem)treeView.SelectedNode.Tag;

            if (item != null && !item.IsDirectory)
            {
                return;
            }
            string dirPath = GetPathOfNode(treeView.SelectedNode);
            string path    = dirPath + "/" + fileInfo.Name;

            FileStream file = File.Open(fileInfo.FullName, FileMode.Open, FileAccess.Read);

            conn.WriteFile(bucket, path, file);
            file.Close();

            // Update the tree view to show the newly-uploaded file.
            Repopulate(treeView.SelectedNode);
        }
Example #23
0
 private void AddDirectoryToTask(string path)
 {
     if (Paths.IsAccessible(path))
     {
         if (Paths.IsDirectory(path))
         {
             var target = new DirectoryItem(path);
             if (!task.TargetDirectories.Contains(target))
             {
                 task.TargetDirectories.Add(target);
             }
             else
             {
                 logger.Debug(
                     string.Format(
                         "Directory '{0}' is already included in the scan task.",
                         path));
             }
         }
         else
         {
             logger.Warn(
                 string.Format(
                     "Attempted to add file to task targets: {0}.",
                     path));
         }
     }
     else
     {
         logger.Warn(
             string.Format(
                 "Invalid path not added to task targets: {0}.",
                 path));
     }
 }
Example #24
0
        private async Task <ItemSyncResult> UpdateFile(DirectoryItem destination, FileInfo fileInfo, FileStream file, CancellationToken token = default(CancellationToken))
        {
            try
            {
                _logger.Verbose("Replacing File {file} on remote with local", fileInfo);
                if (fileInfo.Length < 2147483647)
                {
                    await _hiDriveClient.File
                    .Upload(fileInfo.Name, dir_id : destination.Id, modificationTime : fileInfo.LastWriteTimeUtc,
                            dirModificationTime : fileInfo.Directory.LastWriteTimeUtc, mode : UploadMode.CreateOrUpdate)
                    .ExecuteAsync(file, token);
                }
                else
                {
                    var path      = CombinePaths(destination.Path, fileInfo.Name);
                    var batchSize = 0x10000000;
                    var i         = (int)Math.Ceiling(fileInfo.Length / (double)batchSize);
                    for (long j = 0; j < i; j++)
                    {
                        var stream = new BatchStream(file, j * batchSize, batchSize);
                        await _hiDriveClient.File
                        .Patch(path, modificationTime : fileInfo.LastWriteTimeUtc,
                               offset : j *batchSize)
                        .ExecuteAsync(stream, token);
                    }
                }

                return(new ItemSyncResult(fileInfo.FullName, SyncAction.Updated, SyncState.Successful));
            }
            catch (ServiceException e)
            {
                _logger.Warning("Replacing File failed!", e);
                return(new ItemSyncResult(fileInfo.FullName, SyncAction.Updated, SyncState.Failed, e));
            }
        }
Example #25
0
            /**
             *@brief constructor. This sets up the directory item by filling in the name, path, parent and sub_dirs fields.
             *@param[in] folder_path (string) absolute or relative path to the folder to represent
             *@param[in] folder_name (string) name of the folder to represent
             *@param[in] parent_dir (sulphur.editor.DirectoryItem) parent directory from the directory to represent
             */
            public DirectoryItem(string folder_path, string folder_name, DirectoryItem parent_dir)
            {
                DirectoryInfo info = new DirectoryInfo(folder_path);

                if (info.Exists == false)
                {
                    return;
                }
                path     = info.FullName;
                name     = info.Name;
                parent   = parent_dir;
                editable = true;
                items    = new DirectoryList();
                DirectoryInfo[] sub_dirs = info.GetDirectories();

                relative_path = parent_dir == null?path.Remove(0, Project.directory_path.Length) :
                                    parent_dir.relative_path + path.Remove(0, parent_dir.path.Length);

                if (relative_path.StartsWith("\\") == true)
                {
                    relative_path = relative_path.Remove(0, 1);
                }

                foreach (DirectoryInfo dir in sub_dirs)
                {
                    DirectoryItem item = new DirectoryItem(dir.FullName, dir.Name, this);
                    items.Add(item);
                }
            }
    /// <summary>
    /// Gets the folders that are contained in a specific virtual directory
    /// </summary>
    /// <param name="virtualPath">The virtual directory that contains the folders</param>
    /// <returns>Array of 'DirectoryItem'</returns>
    private DirectoryItem[] GetDirectories(string virtualPath)
    {
        List <DirectoryItem> directoryItems = new List <DirectoryItem>();
        string physicalPath = this.GetPhysicalFromVirtualPath(virtualPath);

        if (physicalPath == null)
        {
            return(null);
        }
        string[] directories;

        try
        {
            directories = Directory.GetDirectories(physicalPath);            // Can throw an exeption ;
            foreach (string dirPath in directories)
            {
                DirectoryInfo dirInfo        = new DirectoryInfo(dirPath);
                string        newVirtualPath = PathHelper.AddEndingSlash(virtualPath, '/') + PathHelper.GetDirectoryName(dirPath) + "/";
                DirectoryItem dirItem        = new DirectoryItem(PathHelper.GetDirectoryName(dirPath),
                                                                 string.Empty,
                                                                 newVirtualPath,
                                                                 PathHelper.AddEndingSlash(virtualPath, '/'),
                                                                 GetPermissions(dirPath),
                                                                 GetFiles(virtualPath),
                                                                 null
                                                                 );
                directoryItems.Add(dirItem);
            }
        }
        catch (IOException)
        {        // The parent directory is moved or deleted
        }

        return(directoryItems.ToArray());
    }
Example #27
0
        public IActionResult Update(long id, [FromBody] DirectoryItem item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var directory = _context.DirectoryItems.FirstOrDefault(t => t.Id == id);

            if (directory == null)
            {
                return(NotFound());
            }

            directory.Title        = item.Title;
            directory.FirstName    = item.FirstName;
            directory.LastName     = item.LastName;
            directory.EmailAddress = item.EmailAddress;
            directory.Phone        = item.Phone;
            directory.WebSite      = item.WebSite;
            directory.isPrivate    = item.isPrivate;

            _context.DirectoryItems.Update(directory);
            _context.SaveChanges();
            return(new NoContentResult());
        }
Example #28
0
        private void _navigateTo(DirectoryItem item, bool isHistoryNav = false)
        {
            // set current path
            _model.CurrentPath = item.GetFullPath();
            if (item.Type == DirectoryItem.ItemType.Directory)
            {
                _model.CurrentChildren = item.Children;

                if (_model.Recent.Where(path => path == item.GetFullPath()).Count() == 0)
                {
                    _model.Recent.Insert(0, item.GetFullPath());
                }

                if (!isHistoryNav)
                {
                    item.RefreshChildren();
                }

                _model.DirectoryCount = item.Children.Where(child => child.Type == DirectoryItem.ItemType.Directory).Count();
                _model.FileCount      = item.Children.Where(child => child.Type == DirectoryItem.ItemType.File).Count();

                _model.FileSize = string.Empty;

                if (!isHistoryNav)
                {
                    _history.Add(item);
                }
            }
            else
            {
                long size = new FileInfo(item.GetFullPath()).Length;
                _model.FileSize = FileUtil.StringifyShort(size);
            }
        }
        public static DirectoryItem ConvertToDirectoryItem(string path)
        {
            string name;
            string extension  = "";
            var    attributes = File.GetAttributes(path);
            var    lastDot    = path.LastIndexOf(".");
            var    lastSlash  = path.LastIndexOf("\\");

            if (lastDot - lastSlash - 1 > 1)
            {
                name = path.Substring(lastSlash + 1, Math.Abs(lastDot - lastSlash - 1));
            }
            else
            {
                name = path.Substring(lastSlash + 1, path.Length - 1 - lastSlash);
            }
            var isFile = !(attributes.HasFlag(FileAttributes.Directory));

            if (isFile)
            {
                extension = path.Substring(lastDot, path.Length - lastDot);
            }
            var result = new DirectoryItem()
            {
                Id            = Guid.NewGuid(),
                ItemPath      = path,
                isFile        = isFile,
                ItemName      = name,
                ItemExtension = isFile ? extension : "",
            };

            return(result);
        }
Example #30
0
            /**
             *@brief constructor. This creates a new assets folder in the working directory this folder will serve as the workspace.
             * This also sets up the folder watcher to watch for folder changes so directory structure is updated even when focus is not on the editor.
             * The same goes for the file watcher.
             */
            public Workspace()
            {
                file_queue_ = new List <FileQueueData>();
                Application.Current.MainWindow.GotKeyboardFocus  += OnMainWindowFocus;
                Application.Current.MainWindow.LostKeyboardFocus += OnMainWindowFocusLost;
                DirectoryInfo info = new DirectoryInfo(Project.directory_path + "\\assets");

                items         = new DirectoryList();
                root          = new DirectoryItem(info.FullName, info.Name, null);
                root.editable = false;

                items.Add(root);

                folder_watcher_      = new FileSystemWatcher();
                folder_watcher_.Path = Project.directory_path + "\\assets";
                folder_watcher_.IncludeSubdirectories = true;
                folder_watcher_.EnableRaisingEvents   = true;
                folder_watcher_.NotifyFilter          = NotifyFilters.DirectoryName;
                folder_watcher_.Renamed += OnFolderWatcherRenamed;
                folder_watcher_.Created += OnFolderWatcherCreated;
                folder_watcher_.Deleted += OnFolderWatcherDeleted;

                file_watcher_      = new FileSystemWatcher();
                file_watcher_.Path = Project.directory_path + "\\assets";
                file_watcher_.IncludeSubdirectories = true;
                file_watcher_.EnableRaisingEvents   = false;
                file_watcher_.Filter       = "*.*";
                file_watcher_.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
                file_watcher_.Renamed     += OnFileWatcherRenamed;
                file_watcher_.Changed     += FileWatcherChanged;
                file_watcher_.Deleted     += FileWatcherDeleted;
                file_watcher_.Created     += FileWatcherCreated;
            }
Example #31
0
        private void ScanDirectory(DirectoryItem dir)
        {
            logger.Trace("Beginning scan of directory: {0}", dir.Path);

            while (scanTask.Status == ScanStatus.PAUSED &&
                   !parallelOptions.CancellationToken.IsCancellationRequested)
            {
                logger.Trace("Thread is held in pause loop");
                Thread.Sleep(10);
            }

            /* Enqueue subdirectories */
            if (dir.Recursive)
            {
                List <DirectoryItem> subDirectories = GetSubDirectories(dir);
                foreach (var directory in subDirectories)
                {
                    discoveredDirectories.Add(directory);
                }
            }
            else
            {
                logger.Trace("Skipping subdirectories of {0} as it is not marked for recursion", dir.Path);
            }

            foreach (var fileItem in GetFiles(dir))
            {
                logger.Trace("Beginning scan of file: {0}", fileItem.AbsolutePath);
                ScanFile(fileItem, FileScanMode.DEFAULT);
            }

            logger.Trace("Finished scan of directory: {0}", dir.Path);
            scannedDirectories.Add(dir);
        }
            public override DirectoryItem ResolveRootDirectoryAsTree(string path)
            {
                // Update all directory items with the additional information (date, owner)
                //DirectoryItem oldItem = base.ResolveRootDirectoryAsTree(    path);

                DirectoryItem oldItem = base.ResolveRootDirectoryAsTree(path);



                foreach (DirectoryItem dirItem in oldItem.Directories)
                {
                    // Get the information from the physical directory
                    DirectoryInfo dInfo = new DirectoryInfo(Context.Server.MapPath(VirtualPathUtility.AppendTrailingSlash(dirItem.Path)));

                    // Add the information to the attributes collection of the item. It will be automatically picked up by the FileExplorer
                    // If the name attribute matches the unique name of a grid column

                    dirItem.Attributes.Add("Datemodi", dInfo.LastWriteTime.ToString());

                    //Type targetType = typeof(System.Security.Principal.NTAccount);
                    //string value = dInfo.GetAccessControl().GetOwner(targetType).Value.Replace("\\", "\\\\");
                    //string ownerName = "Telerik";
                    //dirItem.Attributes.Add("Owner", ownerName);
                }

                //oldItem.Files.OrderBy(f => f.Name);
                return(oldItem);
            }
        public List<Item> GetItems(string path)
        {
            if (!System.IO.Directory.Exists(path))
            {
                return null;
            }

            var items = new List<Item>();

            var dirInfo = new DirectoryInfo(path);

            try
            {
                foreach (var directory in dirInfo.GetDirectories())
                {
                    var item = new DirectoryItem
                    {
                        Name = directory.Name,
                        Path = directory.FullName,
                        Items = GetItems(directory.FullName),
                        IsFolder = true
                    };

                    items.Add(item);
                }

            }
            catch(Exception ex)
            {
                Trace.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace, "EXCEPTION GetItems");
            }

            try
            {
                foreach (var file in dirInfo.GetFiles())
                {
                    if (file.Name.ToLower() != "thumbs.db" && file.Name.ToLower() != "desktop.ini")
                    {
                        var item = new FileItem
                        {
                            Name = file.Name,
                            Path = file.FullName,
                            IsFolder = false
                        };

                        items.Add(item);

                    }
                }

            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace, "EXCEPTION GetItems");
            }

            return items;
        }
        public void Test1()
        {
            var item = new DirectoryItem(@"z:\temp");
            Assert.AreEqual(@"z:\temp", item.DirectoryName);
            Assert.AreEqual(@"z:\temp\a.txt", item.FullPath("a.txt"));

            Assert.Throws<ArgumentException>(() => { new DirectoryItem("a"); });
            Assert.Throws<ArgumentException>(() => { new DirectoryItem(null); });
            Assert.Throws<ArgumentException>(() => { item.FullPath(""); });
            Assert.Throws<ArgumentException>(() => { item.FullPath(@"y:\aaa"); });
        }
Example #35
0
        public void op_Equals_DirectoryItem_whenFalse()
        {
            using (var temp = new TempDirectory())
            {
                var obj = new DirectoryItem
                              {
                                  Name = temp.Info.Name,
                                  Value = temp.Info.FullName
                              };

                var other = new DirectoryItem();

                Assert.False(obj.Equals(other));
            }
        }
		private DirectoryItem[] AddChildDirectoriesToList(ref DirectoryItem[] radDirectories, bool recursive, bool loadFiles)
		{
			var newDirectories = new ArrayList();
		    var invalidFolders = new List<DirectoryItem>();

			foreach (var radDirectory in radDirectories)
			{
			    System.Diagnostics.Debug.WriteLine(DateTime.Now.ToLongTimeString() + " AddChildDirectoriesToList " + radDirectory.Name);

			    var endUserPath = (string) FileSystemValidation.ToEndUserPath(radDirectory.FullPath);

			    var folderPath = radDirectory.FullPath.EndsWith("/") ? radDirectory.FullPath : radDirectory.FullPath + "/";

			    var dnnFolder = DNNValidator.GetUserFolder(folderPath);

			    if (dnnFolder == null)
			    {
                    invalidFolders.Add(radDirectory);
			        continue;
			    }
			    
                //Don't show protected folders
			    if (!string.IsNullOrEmpty(dnnFolder.FolderPath) && dnnFolder.IsProtected)
			    {
                    invalidFolders.Add(radDirectory);
			        continue;
			    }

			    //Don't show Cache folder
			    if (dnnFolder.FolderPath.ToLowerInvariant() == "cache/")
			    {
                    invalidFolders.Add(radDirectory);
			        continue;
			    }

			    var showFiles = new ArrayList();
			    var folderPermissions = PathPermissions.Read;

                if (DNNValidator.CanViewFilesInFolder(dnnFolder))
                {
                    if (DNNValidator.CanAddToFolder(dnnFolder))
                    {
                        folderPermissions = folderPermissions | PathPermissions.Upload;
                    }

                    if (DNNValidator.CanDeleteFolder(dnnFolder))
                    {
                        folderPermissions = folderPermissions | PathPermissions.Delete;
                    }

                    if (loadFiles)
                    {
                        var files = FolderManager.Instance.GetFiles(dnnFolder);
                        foreach (var fileInfo in files)
                        {
                            showFiles.Add(new FileItem(fileInfo.FileName, fileInfo.Extension, fileInfo.Size, "", FileManager.Instance.GetUrl(fileInfo), "", folderPermissions));
                        }
                    }

                    var folderFiles = (FileItem[]) showFiles.ToArray(typeof (FileItem));

                    //Root folder name
                    var dirName = radDirectory.Name;
                    if (dnnFolder.FolderPath == "" && dnnFolder.FolderName == "")
                    {
                        dirName = FileSystemValidation.EndUserHomeDirectory;
                    }

                    DirectoryItem newDirectory;
                    if (recursive)
                    {
                        var directory = TelerikContent.ResolveRootDirectoryAsTree(radDirectory.Path);
                        var tempVar2 = directory.Directories;
                        AddChildDirectoriesToList(ref tempVar2, false, false);
                        newDirectory = new DirectoryItem(dirName, "", endUserPath, "", folderPermissions, folderFiles, tempVar2);
                        radDirectory.Directories = tempVar2;
                    }
                    else
                    {
                        newDirectory = new DirectoryItem(dirName, "", endUserPath, "", folderPermissions, folderFiles, new DirectoryItem[0]);
                    }

                    newDirectories.Add(newDirectory);
                }
                else
                {
                    invalidFolders.Add(radDirectory);
                }
			}
            //remove invalid folders
		    radDirectories = radDirectories.Where(d => !invalidFolders.Contains(d)).ToArray();

		    return (DirectoryItem[])newDirectories.ToArray(typeof(DirectoryItem));
		}
Example #37
0
        /// <summary>
        /// Loads a root directory with given path
        /// </summary>
        /// <param name="path">the root directory path, passed by the FileBrowser</param>
        /// <returns>The root DirectoryItem or null if such does not exist</returns>
        public override DirectoryItem ResolveDirectory(string path)
        {
            DirectoryItem[] directories = GetChildDirectories(path);

            DirectoryItem returnValue = new DirectoryItem(
                GetName(path),
                VirtualPathUtility.AppendTrailingSlash(GetDirectoryPath(path)),
                path,
                string.Empty,
                GetPermissions(path),
                GetChildFiles(path),
                null // Directories are added in ResolveRootDirectoryAsTree()
                );

            return returnValue;
        }
Example #38
0
 /// <summary>
 /// Loads a root directory with given path, where all subdirectories 
 /// contained in the SelectedUrl property are loaded
 /// </summary>
 /// <remarks>
 /// The ImagesPaths, DocumentsPaths, etc properties of RadEditor
 /// allow multiple root items to be specified, separated by comma, e.g.
 /// Photos,Paintings,Diagrams. The FileBrowser class calls the 
 /// ResolveRootDirectoryAsTree method for each of them.
 /// </remarks>
 /// <param name="path">the root directory path, passed by the FileBrowser</param>
 /// <returns>The root DirectoryItem or null if such does not exist</returns>
 public override DirectoryItem ResolveRootDirectoryAsTree(string path)
 {
     DirectoryItem returnValue = new DirectoryItem(GetName(path),
                                                     GetDirectoryPath(path),
                                                     path,
                                                     string.Empty,
                                                     GetPermissions(path),
                                                     null, // The files  are added in ResolveDirectory()
                                                     GetChildDirectories(path));
     return returnValue;
 }
Example #39
0
        private DirectoryItem[] GetChildDirectories(string path)
        {
            List<DirectoryItem> directories = new List<DirectoryItem>();
            try
            {
                DataRow[] childRows = GetChildDirectoryRows(path);
                int i = 0;
                while (i < childRows.Length)
                {
                    DataRow childRow = childRows[i];
                    string name = childRow["Name"].ToString();
                    string itemFullPath = VirtualPathUtility.AppendTrailingSlash(CombinePath(path, name));

                    DirectoryItem newDirItem = new DirectoryItem(name,
                                                                 string.Empty,
                                                                 itemFullPath,
                                                                 string.Empty,
                                                                 GetPermissions(itemFullPath),
                                                                 null, // The files are added in ResolveDirectory()
                                                                 null // Directories are added in ResolveRootDirectoryAsTree()
                                                                 );

                    directories.Add(newDirItem);
                    i = i + 1;
                }
                return directories.ToArray();
            }
            catch (Exception)
            {
                return new DirectoryItem[] { };
            }
        }
 public void ProcessTree(DirectoryItem parent, string parentPath, FileSystemEntry entry)
 {
     if (entry is FileEntry)
       ProcessFile(parentPath, (FileEntry)entry);
     else
       ProcessDirectory(parent, parentPath, (DirectoryEntry)entry);
 }
 private void ProcessDirectory(DirectoryItem parent, string parentPath, DirectoryEntry entry)
 {
     DirectoryCount++;
     DirectoryItem newParent;
     string newPath;
     if (parent == null) {
       RootDirectory = new TreeStats.DirectoryItem();
       newParent = RootDirectory;
       newPath = parentPath;
     } else {
       var newDir = new DirectoryItem {
     Name = entry.Name
       };
       parent.Children.Add(newDir);
       newParent = newDir;
       newPath = Path.Combine(parentPath, entry.Name);
     }
     foreach (var x in entry.Entries) {
       ProcessTree(newParent, newPath, x);
     }
 }
Example #42
0
 public void Set(string strItem, string strDir)
 {
   if (strItem == null) return;
   if (strDir == null) return;
   foreach (DirectoryItem item in m_history)
   {
     if (item.Dir == strDir)
     {
       item.Item = strItem;
       return;
     }
   }
   DirectoryItem newItem = new DirectoryItem(strItem, strDir);
   m_history.Add(newItem);
 }
	public override DirectoryItem ResolveRootDirectoryAsTree(string path)
	{
		string physicalPath;
		string virtualPath = string.Empty;

		if (PathHelper.IsSharedPath(path) || PathHelper.IsPhysicalPath(path))
		{// The path is a physical path
			physicalPath = path;

			foreach (KeyValuePair<string, string> mappedPath in MappedPaths)
			{
				// Checks whether a mapping exists for the current physical path
				// 'mappedPath.Value' does not end with trailing slash. It looks like : "C:\Path\Dir"
				if (physicalPath.StartsWith(mappedPath.Value, StringComparison.CurrentCultureIgnoreCase))
				{// Exists 

					// Get the part of the physical path which does not contain the mappeed part
					string restOfPhysicalPath = physicalPath.Substring(mappedPath.Value.Length);

					// 'mappedPath.Value' does not end with '\'
					// // The 'restOfVirtualPath' is something like Folder_1/SubFolder_2/ ==> convert it to Folder_1\SubFolder_2\
					virtualPath = mappedPath.Key + restOfPhysicalPath.Replace('\\', '/');


					virtualPath = PathHelper.AddEndingSlash(virtualPath, '/');
					break;// Exit the 'foreach' loop ;
				}
			}
		}
		else
		{// Virtual path ;
			virtualPath = PathHelper.AddEndingSlash(path, '/');
			physicalPath = this.GetPhysicalFromVirtualPath(path);
			if (physicalPath == null)
				return null;
		}

		DirectoryItem result = new DirectoryItem(PathHelper.GetDirectoryName(physicalPath),
													string.Empty,
													virtualPath,
													string.Empty,
													GetPermissions(physicalPath),
													new FileItem[] { }, // Files are added in the ResolveDirectory method
													GetDirectories(virtualPath)
												);

		return result;
	}
	/// <summary>
	/// Gets the folders that are contained in a specific virtual directory
	/// </summary>
	/// <param name="virtualPath">The virtual directory that contains the folders</param>
	/// <returns>Array of 'DirectoryItem'</returns>
	private DirectoryItem[] GetDirectories(string virtualPath)
	{
		List<DirectoryItem> directoryItems = new List<DirectoryItem>();
		string physicalPath = this.GetPhysicalFromVirtualPath(virtualPath);
		if (physicalPath == null)
			return null;
		string[] directories;

		try
		{
			directories = Directory.GetDirectories(physicalPath);// Can throw an exeption ;
			foreach (string dirPath in directories)
			{
				DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
				string newVirtualPath = PathHelper.AddEndingSlash(virtualPath, '/') + PathHelper.GetDirectoryName(dirPath) + "/";
				DirectoryItem dirItem = new DirectoryItem(PathHelper.GetDirectoryName(dirPath),
															string.Empty,
															newVirtualPath,
															PathHelper.AddEndingSlash(virtualPath, '/'),
															GetPermissions(dirPath),
                                                            new FileItem[] { }, // Files are added in the ResolveDirectory method
															null
														  );
				directoryItems.Add(dirItem);
			}
		}
		catch (IOException)
		{// The parent directory is moved or deleted

		}

		return directoryItems.ToArray();
	}
	public override DirectoryItem ResolveDirectory(string virtualPath)
	{
		string physicalPath;
		physicalPath = this.GetPhysicalFromVirtualPath(virtualPath);

		if (physicalPath == null)
			return null;

		DirectoryItem result = new DirectoryItem(PathHelper.GetDirectoryName(physicalPath),
													virtualPath,
													virtualPath,
													virtualPath,
													GetPermissions(physicalPath),
													GetFiles(virtualPath),
													new DirectoryItem[] { }// Directories are added in ResolveRootDirectoryAsTree method
												);

		return result;
	}
 public override DirectoryItem ResolveRootDirectoryAsTree(string path)
 {
     MainDataSet.ArticleRow articleRow = null;
     DirectoryItem returnValue = null;
     Guid articleGuid = Guid.Empty;
     try { articleGuid = new Guid(path); }
     catch { }
     if (articleGuid != Guid.Empty)
     {
         MainDataSet.ArticleDataTable dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid);
         if (dtArticle.Count > 0)
         {
             articleRow = dtArticle[0];
             string fullName = this.ArticleTableAdapter.GetAlternateId(articleGuid);
             if (string.IsNullOrEmpty(fullName))
                 fullName = articleRow.ArticleGuid.ToString("N");
             returnValue = new DirectoryItem(
                 articleRow.Subject, articleRow.Subject + "/", fullName, string.Empty, fullPermissions, GetChildFiles(articleRow),
                 GetChildDirectories(articleRow));
         }
     }
     if (returnValue == null) returnValue = this.GetDefaultDirectoryItem();
     return returnValue;
 }
        private void AddUserFolder(ref DirectoryItem[] directories, bool loadFiles)
        {
            var usersMainFolder = directories.SingleOrDefault(d => d.Name.ToUpper() == "USERS");
            if(usersMainFolder != null)
            {
                var userFolder = FolderManager.Instance.GetUserFolder(CurrentUser);
                usersMainFolder.Name = FolderManager.Instance.MyFolderName;
                string endUserPath = (string) FileSystemValidation.ToEndUserPath(userFolder.FolderPath);
                usersMainFolder.FullPath = endUserPath;

                var folderPermissions = PathPermissions.Read;
                if (DNNValidator.CanViewFilesInFolder((FolderInfo)userFolder))
                {
                    if (DNNValidator.CanAddToFolder((FolderInfo)userFolder))
                    {
                        folderPermissions = folderPermissions | PathPermissions.Upload;
                    }

                    if (DNNValidator.CanDeleteFolder((FolderInfo)userFolder))
                    {
                        folderPermissions = folderPermissions | PathPermissions.Delete;
                    }
                }
                usersMainFolder.Permissions = folderPermissions;

                //var showFiles = new ArrayList();
                //if (loadFiles)
                //{
                //    var files = FolderManager.Instance.GetFiles((FolderInfo)userFolder);
                //    foreach (var fileInfo in files)
                //    {
                //        showFiles.Add(new FileItem(fileInfo.FileName, fileInfo.Extension, fileInfo.Size, "", FileManager.Instance.GetUrl(fileInfo), "", folderPermissions));
                //    }
                //}
                //var folderFiles = (FileItem[]) showFiles.ToArray(typeof (FileItem));

                //var newDirectory = new DirectoryItem(userFolder.DisplayName, "", endUserPath, "", folderPermissions, folderFiles, new DirectoryItem[0]);
                

            }
            
        }
Example #48
0
        public void prop_Info_get()
        {
            using (var temp = new TempDirectory())
            {
                var expected = temp.Info.FullName;
                var obj = new DirectoryItem
                              {
                                  Value = expected
                              };
                var actual = obj.Info.FullName;

                Assert.Equal(expected, actual);
            }
        }
        public override DirectoryItem ResolveRootDirectoryAsTree(string path)
        {
            DirectoryItem originalFolder = base.ResolveRootDirectoryAsTree(path);
            DirectoryItem[] originalDirectories = originalFolder.Directories;

            List<DirectoryItem> filteredDirectories = new List<DirectoryItem>();

            // Filter the folders
            foreach (DirectoryItem originalDir in originalDirectories)
            {
                //Don't show recycle bin
                if (originalDir.Name == "_recyclebin")
                {
                    continue;
                }

                //Don't show DNN hidden folders
                if (originalDir.Name.StartsWith("_"))
                {
                    continue;
                }

                //Don't show folders without Read permission
                if (!QuickDocsController.CanRead(originalDir.Path, userID, portalID))
                {
                    continue;
                }

                filteredDirectories.Add(originalDir);
            }

            DirectoryItem newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, originalFolder.Files, filteredDirectories.ToArray());

            return newFolder;
        }
        public override DirectoryItem ResolveDirectory(string path)
        {
            DirectoryItem[] directories;
            DirectoryItem returnValue = null;
            MainDataSet.ArticleRow articleRow = null;
            MainDataSet.ArticleDataTable dtArticle = null;

            Guid articleGuid = Guid.Empty;
            try { articleGuid = new Guid(path); }
            catch { }
            if (articleGuid != Guid.Empty)
                dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid);
            else
                dtArticle = this.ArticleTableAdapter.GetDataByAlternateId(path);
            if (dtArticle.Count > 0) articleRow = dtArticle[0];

            //if (DisplayMode == FileBrowserDisplayMode.List)
                directories = new DirectoryItem[] { };
            //else
            //{
            //    if (articleRow != null)
            //        directories = GetChildDirectories(articleRow);
            //    else directories = new DirectoryItem[] { };
            //}
            if (articleRow != null)
                returnValue = new DirectoryItem(articleRow.Subject, articleRow + "/", articleRow + "/", articleRow + "/", fullPermissions, GetChildFiles(articleRow),
                    directories);
            else
                returnValue = this.GetDefaultDirectoryItem();
            return returnValue;
        }
		private DirectoryItem AddChildDirectoriesToList( DirectoryItem radDirectory)
		{
            var parentFolderPath = radDirectory.FullPath.EndsWith("/") ? radDirectory.FullPath : radDirectory.FullPath + "/";
            if (parentFolderPath.StartsWith(PortalSettings.HomeDirectory))
		    {
                parentFolderPath = parentFolderPath.Remove(0, PortalSettings.HomeDirectory.Length);
		    }

		    var dnnParentFolder = FolderManager.Instance.GetFolder(PortalSettings.PortalId, parentFolderPath);
		    if (!DNNValidator.CanViewFilesInFolder(dnnParentFolder.FolderPath))
		    {
		        return null;
		    }

		    var dnnChildFolders = FolderManager.Instance.GetFolders(dnnParentFolder).Where(folder => (FileSystemValidation.HasPermission(folder, "BROWSE,READ")));
            var radDirectories = new List<DirectoryItem>();
            foreach (var dnnChildFolder in dnnChildFolders)
            {
                if (!dnnChildFolder.FolderPath.ToLowerInvariant().StartsWith("cache/") 
                    && !dnnChildFolder.FolderPath.ToLowerInvariant().StartsWith("users/")
                    && !dnnChildFolder.FolderPath.ToLowerInvariant().StartsWith("groups/"))
                {
                        var radSubDirectory =
                            TelerikContent.ResolveDirectory(FileSystemValidation.ToVirtualPath(dnnChildFolder.FolderPath));
                        radSubDirectory.Permissions = FileSystemValidation.TelerikPermissions(dnnChildFolder);
                        radDirectories.Add(radSubDirectory);
                }
            }

            radDirectory.Files = IncludeFilesForCurrentFolder(dnnParentFolder);

		    if (parentFolderPath == "")
            {
                var userFolder = FolderManager.Instance.GetUserFolder(PortalSettings.UserInfo);
                if (userFolder.PortalID == PortalSettings.PortalId)
                {
                    var radUserFolder = TelerikContent.ResolveDirectory(FileSystemValidation.ToVirtualPath(userFolder.FolderPath));
                    radUserFolder.Name = DNNValidator.GetString("MyFolder");
                    radUserFolder.Permissions = FileSystemValidation.TelerikPermissions(userFolder);
                    radDirectories.Add(radUserFolder);
                }
            }
            
		    radDirectory.Directories = radDirectories.ToArray();
            return radDirectory;
		}