hiding hidden directories

2 posts, 0 answers
  1. Paul
    Paul avatar
    28 posts
    Member since:
    May 2016

    Posted 26 Sep Link to this post

    Hi I have been able to hide hidden files but i cant seem to get the directories to hide my files code is -

    public override DirectoryItem ResolveDirectory(string virtualPath)
    {

            DirectoryItem basedir = base.ResolveDirectory(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
    );

            // Update all file items with the additional information (date, owner)
            DirectoryItem oldItem = base.ResolveDirectory(physicalPath);
            List<FileItem> visibleFiles = new List<FileItem>();
            foreach (FileItem fileItem in result.Files)
            {
                // Get the information from the physical file
                FileInfo fInfo = new FileInfo(physicalPath + "\\" + fileItem.Name);
                // 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
                fileItem.Attributes.Add("CreationDate", fInfo.CreationTimeUtc.ToString());
                fileItem.Attributes.Add("ModifiedDate", fInfo.LastWriteTime.ToString());

                
                
                FileAttributes fileattr = File.GetAttributes(physicalPath + "\\" + fileItem.Name);
                if((fileattr & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    visibleFiles.Add(fileItem);
                }
            }

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

            return result1;
    }

     

    Which works really well my Directory code is code is - > 

       public override DirectoryItem ResolveRootDirectoryAsTree(string path)
    {

            
            

            string physicalPath;
    string virtualPath = string.Empty;       

    if (PathHelper.IsSharedPath(path) || PathHelper.IsPhysicalPath(path))
    {
    physicalPath = path;

    foreach (KeyValuePair<string, string> mappedPath in MappedPaths)
    {

    if (physicalPath.StartsWith(mappedPath.Value, StringComparison.CurrentCultureIgnoreCase))
    {


    string restOfPhysicalPath = physicalPath.Substring(mappedPath.Value.Length);


    virtualPath = mappedPath.Key + restOfPhysicalPath.Replace('\\', '/');


    virtualPath = PathHelper.AddEndingSlash(virtualPath, '/');
    break;
    }
    }
    }
    else
    {
    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;
    }

     

    Any help would be much appreciated.

  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 29 Sep Link to this post

    Hello Paul,

     

    Basically, you should handle that in the ResolveRootDirectoryAsTree method (as seggested in this post: http://www.telerik.com/forums/radfileexplorer-and-hidden-folders#2jrGnmFt_kO1L21RRzVMXQ) and programmatically filter the hidden folders so that they are not added to the Directories collection. 

     

    A basic filtering logic for folders is available here: http://www.telerik.com/support/kb/aspnet-ajax/fileexplorer/details/hide-certain-directories-and-files-in-radfileexplorer

     

    Regards,
    Ianko
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top