private void FolderFolderScannedEvent(object sender, Folder.FolderScannedEventArgs e)
 {
     _folderScanCounter++;
     //UpdateScanStatusText();
 }
示例#2
0
 public FileEventArgs(File file, Folder folder)
 {
     File = file;
     Folder = folder;
 }
 private void FolderFileActionEvent(object sender, Folder.FileActionEventArgs e)
 {
     FileEventText = e.Message;
     OnPropertyChanged("FileEventText");
 }
示例#4
0
 private static IEnumerable<Folder> GetSubfolders(Folder root, string folder, Folder parent)
 {
     var directories = Directory.GetDirectories(folder);
     foreach (var directory in directories)
         yield return Folder.CreateFolder(root, directory, parent);
 }
示例#5
0
        private static Folder CreateFolder(Folder root, string folderPath, Folder parent)
        {
            if (folderPath.EndsWith(@":\")) throw new InvalidOperationException();

            return new Folder(folderPath, root, parent);
        }
示例#6
0
        //Factory
        private static Folder CreateDrive(string driveLetter, bool loadTreeAsync)
        {
            if (!driveLetter.EndsWith(@":\")) throw new InvalidOperationException();

            //Look for folder in the loaded static list (Repository)
            var folder = RootFolderList.FirstOrDefault(itm => string.Compare(itm.FullName, driveLetter) == 0);
            if (folder == null)
            {
                lock (RootFolderList) //Check-lock-check pattern
                {
                    folder = RootFolderList.FirstOrDefault(itm => string.Compare(itm.FullName, driveLetter) == 0);
                    if (folder == null)
                    {
                        folder = new Folder(driveLetter, loadTreeAsync);
                        RootFolderList.Add(folder);
                    }
                }
            }
            return folder;
        }
示例#7
0
        /// <summary>
        /// Drive
        /// </summary>
        /// <param name="driveLetter"></param>
        /// <param name="loadTreeAsync"></param>
        private Folder(string driveLetter, bool loadTreeAsync)
            : this()
        {
            _root = this;
            _parent = null;
            _syncRootChildren = new object();
            _syncRootFiles = new object();
            FullName = driveLetter;

            if (!IsDrive ) throw new InvalidOperationException();

            //If the folder is a drive, start a thread that loads subfolders
            try
            {
                //Start listening to events on the drive
                _fileSystemWatcher = new FileSystemWatcher();
                _fileSystemWatcher.Path = FullName;
                _fileSystemWatcher.Filter = "*.*";
                _fileSystemWatcher.IncludeSubdirectories = true;
                _fileSystemWatcher.EnableRaisingEvents = true;
                _fileSystemWatcher.Changed += FileSystemWatcherChanged;
                _fileSystemWatcher.Created += FileSystemWatcherCreated;
                //_fileSystemWatcher.Renamed += _fileSystemWatcher_Renamed;
                _fileSystemWatcher.Deleted += FileSystemWatcherDeleted;

                _thread = new Thread(LoadSizeEngine) { Name = string.Format("LoadDrive{0}", FullName.Substring(0, 1)), IsBackground = true, Priority = ThreadPriority.BelowNormal };
                if (loadTreeAsync)
                {
                    //Automatically starts a new scanner thread for each logical drive.
                    //Only do this for the C-drive, others have to be started manually

                    if (driveLetter.StartsWith("C"))
                        _thread.Start();
                }
            }
            catch(ArgumentException exp)
            {
                if (string.Compare(  exp.Message, string.Format( "The directory name {0} is invalid.", FullName )) == 0 )
                {
                    Message = exp.Message;
                    _fileSystemWatcher = null;
                }
                else
                    throw;
            }
        }
示例#8
0
        /// <summary>
        /// Subfolder
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="root"></param>
        /// <param name="parent"></param>
        private Folder(string fullName, Folder root, Folder parent)
            : this()
        {
            _root = root;
            _parent = parent;
            FullName = fullName;

            if (IsDrive) throw new InvalidOperationException();
        }