Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public virtual bool AllowShowFile(FiInfo file)
        {
            if (file.Name.EndsWith(".lnk", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            if (null != DefaultSettings.MiscSettings.CurrentFilter)
            {
                int position = DefaultSettings.MiscSettings.CurrentFilter.Filter.IndexOf(".");
                if (position > 0)
                {
                    string end = DefaultSettings.MiscSettings.CurrentFilter.Filter.Substring(position + 1);
                    if (end.Trim() != "*")
                    {
                        if (file.Name.EndsWith(end, StringComparison.InvariantCultureIgnoreCase))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Пример #2
0
 internal FileSystemInfo(FileSystemManager parent, string name, string path, bool loadDirectories = false, bool loadFiles = false)
 {
     Parent = parent;
     Name = name;
     Path = path;
     Drives = new DrvInfo[0];
     Directories = new FolderInfo[0];
     Files = new FiInfo[0];
     if (loadDirectories)
         LoadDirectories();
     if (loadFiles)
         LoadFiles();
 }
Пример #3
0
 internal FileSystemInfo(FileSystemManager parent, string name, string path, bool loadDirectories = false, bool loadFiles = false)
 {
     Parent      = parent;
     Name        = name;
     Path        = path;
     Drives      = new DrvInfo[0];
     Directories = new FolderInfo[0];
     Files       = new FiInfo[0];
     if (loadDirectories)
     {
         LoadDirectories();
     }
     if (loadFiles)
     {
         LoadFiles();
     }
 }
Пример #4
0
        public override void LoadFiles()
        {
            try
            {
                if (Exists)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(Path);
                    FileInfo[] files = dirInfo.GetFiles(String.IsNullOrWhiteSpace(Parent.FileSearchPattern) != true ? Parent.FileSearchPattern : "*.*", SearchOption.TopDirectoryOnly);

                    List<FiInfo> list = new List<FiInfo>();
                    for (int i = 0; i < files.Length; i++)
                    {
                        if (!files[i].Attributes.HasFlag(FileAttributes.System))
                        {
                            string name = files[i].Name;
                            string path = files[i].FullName;
                            list.Add(new FiInfo(Parent, name, path, files[i].Length));
                        }
                    }
                    Files = list.ToArray();
                }
                else
                {
                    Files = new FiInfo[0];
                }
            }
            catch (UnauthorizedAccessException)
            {
                HasErrors = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                IsFilesLoaded = true;
            }
        }
Пример #5
0
        public override void LoadFiles()
        {
            try
            {
                if (Exists)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(Path);
                    FileInfo[]    files   = dirInfo.GetFiles(String.IsNullOrWhiteSpace(Parent.FileSearchPattern) != true ? Parent.FileSearchPattern : "*.*", SearchOption.TopDirectoryOnly);

                    List <FiInfo> list = new List <FiInfo>();
                    for (int i = 0; i < files.Length; i++)
                    {
                        if (!files[i].Attributes.HasFlag(FileAttributes.System))
                        {
                            string name = files[i].Name;
                            string path = files[i].FullName;
                            list.Add(new FiInfo(Parent, name, path, files[i].Length));
                        }
                    }
                    Files = list.ToArray();
                }
                else
                {
                    Files = new FiInfo[0];
                }
            }
            catch (UnauthorizedAccessException)
            {
                HasErrors = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                IsFilesLoaded = true;
            }
        }
Пример #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public virtual bool AllowShowFile(FiInfo file)
        {
            if (file.Name.EndsWith(".lnk", StringComparison.InvariantCultureIgnoreCase))
                return false;

            if (null != DefaultSettings.MiscSettings.CurrentFilter)
            {
                int position = DefaultSettings.MiscSettings.CurrentFilter.Filter.IndexOf(".");
                if (position > 0)
                {
                    string end = DefaultSettings.MiscSettings.CurrentFilter.Filter.Substring(position+1);
                    if (end.Trim() != "*")
                    {
                        if (file.Name.EndsWith(end, StringComparison.InvariantCultureIgnoreCase))
                            return true;
                        else
                            return false;
                    }
                }
            }

            return true;
        }