private void OnFileRemoved(string name) { if (FileRemoved != null) { FileRemoved.Invoke(name); } }
private void chat_FileRemoved(BitChat chat, SharedFile sharedFile) { if (_sharedFile == sharedFile) { FileRemoved?.Invoke(this, EventArgs.Empty); } }
/* * Add the given content file. * Will notify the FileAdded event after adding. * If a file with the given name already exists and is deleted, * it is replaced with the given one. * If a file with the given name already exists and is not deleted, * it will not be replaced unless the "overwrite" parameter is set to true. */ public void Add(PackedFile file, bool overwrite = false) { if (containedFiles.ContainsKey(file.Name)) { PackedFile contained = null; foreach (var f in containedFiles) { if (f.Value.Name == file.Name) { contained = f.Value; break; } } if (contained.Deleted || overwrite) { containedFiles.Remove(file.Name); FileRemoved?.Invoke(contained); } else { // don't add the file return; } } containedFiles.Add(file.Name, file); file.IsAdded = true; file.Parent = this; FileAdded?.Invoke(file); }
public void RemoveFile(ISourceFile file) { file.Parent?.Items.Remove(file); SourceFiles.Remove(file); IoC.Get <IShell>().RemoveDocument(file); FileRemoved?.Invoke(this, file); }
/// <summary> /// начинает контроль за заданной папкой /// </summary> /// <param name="path">путь к папке</param> public void StartControl(object path) { string _path = path as string; controlDirectorySize = DirSize(new DirectoryInfo(_path)); fileList = InitFileList(_path); directoryList = InitDirectoryList(_path); while (true) { if (controlDirectorySize != DirSize(new DirectoryInfo(_path))) // если размер папки изменился { if (!CheckDirectoryChange(_path)) // если в контролируемую директорию не было добавлено или удалено ПАПКУ { List <File> currentlist = InitFileList(_path); if (fileList.Count < currentlist.Count) //если файл был добавлен { foreach (var item in currentlist) { if (!ContainsItem(fileList, item)) { FileAdded.Invoke(item); if (Synchronaizer.IsDisableChangeFolder) { System.IO.File.Delete(item.Path); FileRemoved.Invoke(item); } } } } else if (fileList.Count > currentlist.Count) // если файл был удален { foreach (var item in fileList) { if (!ContainsItem(currentlist, item)) { FileRemoved.Invoke(item); } } } else // размер файла был изменен { for (int i = 0; i < currentlist.Count; i++) { if (fileList[i].Size != currentlist[i].Size) // дизнаемся размер которого файла было изменено { FileChanged.Invoke(fileList[i]); } } } controlDirectorySize = DirSize(new DirectoryInfo(_path)); fileList = InitFileList(_path); } } Thread.Sleep(CheckInterval); // интервал проверки } }
public bool Remove(string fi) { bool bremove = base.Remove(fi); if (bremove && FileRemoved != null) { FileRemoved.Invoke(this, EventArgs.Empty); } InvokePropertyChanged("Files"); return(bremove); }
private void Watcher_Deleted(object sender, FileSystemEventArgs e) { string ext = Path.GetExtension(e.FullPath); if (ext.Length == 0) { FolderRemoved?.Invoke(e.FullPath); } else if (PassesFilter(e.FullPath)) { FileRemoved?.Invoke(e.FullPath); } }
/// <summary> /// Remove File only from memory, not from disc, use RemoveAsync to remove the File from disc /// </summary> /// <param name="Uri">Uri of file to remove</param> public void Remove(string Uri) { if (_dict.ContainsKey(Uri)) { var temp = _dict[Uri]; FileRemoving?.Invoke(this, new FileRemovingArgs(temp)); _dict.Remove(Uri); FileRemoved?.Invoke(this, new FileRemovedArgs(temp)); } else { throw new ArgumentException("Uri isn't in the collection"); } }
/// <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); }
private void OnFileSystemEvent(object sender, FileSystemEventArgs e) { // ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault switch (e.ChangeType) { case WatcherChangeTypes.Created: FileAdded?.Invoke(this, e.FullPath); break; case WatcherChangeTypes.Deleted: FileRemoved?.Invoke(this, e.FullPath); break; case WatcherChangeTypes.Changed: FileRemoved?.Invoke(this, e.FullPath); if (File.Exists(e.FullPath)) { FileAdded?.Invoke(this, e.FullPath); } break; } }
internal void OnFileRemoved(FileEventArgs args) { FileRemoved?.Invoke(this, args); }
protected virtual void OnFileRemoved(FileAddedEventArgs e) { FileRemoved?.Invoke(this, e); }
private void OnFileRemoved(object sender, FileRemovedArgs e) { _dict.Remove(e.File.Uri.AbsoluteUri); FileRemoved?.Invoke(this, e); }