public void Remove(Guid id) { var handle = handles.FirstOrDefault(x => x.Id == id); if (handle != null) { handles.RemoveAll(x => x.Id == id); // Notify if last handle removed if (LastHandleRemoved != null && Count(handle.Path) == 0) { var e = new FileHandleEventArgs(handle); LastHandleRemoved(this, e); } } }
private void OnLastHandleRemoved(object sender, FileHandleEventArgs e) { if (File.Exists(e.Handle.Path)) { if (totalSize != null) { totalSize -= e.Handle.Size; } File.Delete(e.Handle.Path); } }