Пример #1
0
 public void GetFileInfo(DirectoryInfo DirectoryInfo, ref FileFolderInfo items)
 {
     if (!System.IO.Directory.Exists(DirectoryInfo.FullName))
     {
         return;
     }
     if (!SelectedFilter.Contains("*.*"))
     {
         foreach (System.IO.FileInfo directoryinfo in DirectoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Where(s => SelectedFilter.Split('|')[1].Contains(s.Extension.ToLower())).Where(s => !AvoidedFilePaths.Contains(s.FullName)) /*.OrderByDescending(dir=>dir.LastWriteTime)*/)
         {
             if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && directoryinfo.Extension != "")
             {
                 items.FileFolders.Add(new FileFolderInfo
                 {
                     Name         = directoryinfo.Name,
                     Path         = directoryinfo.FullName,
                     DateModified = directoryinfo.LastWriteTime,
                     FileSize     = directoryinfo.Length,
                     IsFile       = true
                 });
             }
         }
     }
     else
     {
         foreach (System.IO.FileInfo directoryinfo in DirectoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Where(s => !AvoidedFilePaths.Contains(s.FullName)) /*.OrderByDescending(dir => dir.LastWriteTime)*/)
         {
             if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && directoryinfo.Extension != "")
             {
                 items.FileFolders.Add(new FileFolderInfo
                 {
                     Name         = directoryinfo.Name,
                     Path         = directoryinfo.FullName,
                     DateModified = directoryinfo.LastWriteTime,
                     FileSize     = directoryinfo.Length,
                     IsFile       = true
                 });
             }
         }
     }
 }
Пример #2
0
 public void GetDirectoryData(DirectoryInfo DirectoryInfo, ref FileFolderInfo folder)
 {
     try
     {
         foreach (DirectoryInfo directoryinfo in DirectoryInfo.GetDirectories("*.*", SearchOption.TopDirectoryOnly).Where(s => !AvoidedFilePaths.Contains(s.FullName)))
         {
             if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
             {
                 folder.FileFolders.Add(new FileFolderInfo
                 {
                     Name         = directoryinfo.Name,
                     Path         = directoryinfo.FullName,
                     IsDirectory  = true,
                     DateModified = directoryinfo.LastWriteTime
                                    //Files= GetFileInfo(directoryinfo),
                                    //Folders=GetDirectoryData(directoryinfo)
                 });
             }
         }
     }
     catch (Exception e)
     {
     }
 }
Пример #3
0
        public void loadTreeData()
        {
            Drives = new ObservableCollection <FileFolderInfo>();

            //add desktop
            FileFolderInfo desktop = new FileFolderInfo();

            desktop.FileFolders = new ObservableCollection <FileFolderInfo>();
            DirectoryInfo tmp = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));

            GetDirectoryData(tmp, ref desktop);
            GetFileInfo(tmp, ref desktop);
            desktop.IsDrive = true;
            desktop.Name    = "Desktop";
            desktop.Path    = tmp.FullName;
            Drives.Add(desktop);

            //add other drivers
            foreach (DriveInfo info in DriveInfo.GetDrives())
            {
                if (!AvoidedFilePaths.Split(',').Contains(info.RootDirectory.FullName))
                {
                    if (info.IsReady)
                    {
                        FileFolderInfo harddriveinfo = new FileFolderInfo();
                        harddriveinfo.FileFolders = new ObservableCollection <FileFolderInfo>();
                        GetDirectoryData(info.RootDirectory, ref harddriveinfo);
                        GetFileInfo(info.RootDirectory, ref harddriveinfo);
                        harddriveinfo.IsDrive = true;
                        harddriveinfo.Name    = info.Name;
                        harddriveinfo.Path    = info.RootDirectory.FullName;
                        Drives.Add(harddriveinfo);
                    }
                }
            }
        }