Пример #1
0
        private void Watcher_Created(object sender, FileSystemEventArgs e)
        {
            string ext = Path.GetExtension(e.FullPath);

            if (ext.Length == 0)
            {
                FolderAdded?.Invoke(e.FullPath);
            }
            else if (PassesFilter(e.FullPath))
            {
                FileAdded?.Invoke(e.FullPath);
            }
        }
Пример #2
0
        public IProjectFolder AddFolder(string name)
        {
            if (_folders.Any(f => f.FolderName == name))
            {
                throw new ArgumentException("Folder with the same name already exists in this folder.");
            }

            var folderPath = Path.Combine(FolderPath, name);

            Directory.CreateDirectory(folderPath);
            var newFolder = new ProjectFolder(folderPath);

            _folders.Add(newFolder);
            FolderAdded?.Invoke(this, new ProjectFolderAddedEventArgs(newFolder));
            return(newFolder);
        }
Пример #3
0
        /// <summary>
        /// проверяет папку на предмет изменений
        /// </summary>
        /// <param name="path">путь к папке</param>
        /// <returns>если содержимое папки изменилось возвращает true</returns>
        bool CheckDirectoryChange(string path)
        {
            var currentdirectorylist = InitDirectoryList(path);

            if (directoryList.Count < currentdirectorylist.Count) // если папку было добавлено
            {
                foreach (var item in currentdirectorylist)
                {
                    if (!ContainsItem(directoryList, item))
                    {
                        FolderAdded.Invoke(item);
                        if (Synchronaizer.IsDisableChangeFolder)
                        {
                            System.IO.Directory.Delete(item.Path, true);
                            FileRemoved.Invoke(item);
                            currentdirectorylist.Remove(item);
                        }
                    }
                    break;
                }
                directoryList = currentdirectorylist;
                fileList      = InitFileList(path);
                return(true);
            }
            else if (directoryList.Count > currentdirectorylist.Count) // если папку было удалено

            {
                foreach (var item in directoryList)
                {
                    if (!ContainsItem(currentdirectorylist, item))
                    {
                        FolderRemoved.Invoke(item);
                        break;
                    }
                }
                directoryList = currentdirectorylist;
                fileList      = InitFileList(path);
                return(true);
            }
            return(false);
        }
Пример #4
0
 protected virtual void OnFolderAdded(BookmarkFolderChangeEventArgs e)
 {
     FolderAdded.Invoke(this, e);
 }