public string Move(string name) { var old_path = CurrentPath; var sep = Path.DirectorySeparatorChar; var path = name.Replace(':', sep).Replace('/', sep); path = Path.GetFullPath(Path.Combine(CurrentPath, path)); name = ""; if (File.Exists(path)) { name = Path.GetFileName(path); path = Path.GetDirectoryName(path); } if (!Directory.Exists(path)) { return(null); } if (!path.StartsWith(RootDirectory)) { return(null); } if (old_path != path) { CurrentDirectory = path.Replace(RootDirectory, ""); if (CurrentDirectory.Length > 0 && CurrentDirectory[0] == sep) { CurrentDirectory = CurrentDirectory.Remove(0, 1); } DirectoryWatcher.Path = CurrentPath; DirectoryWatcher.EnableRaisingEvents = true; DirectoryChanged?.Invoke(this, new WalkerEventArgs(old_path, path)); } return(name); }
private void RecursivelyChangeTimeStamp(Folder folder, DateTime newDt) { // Change this folder. var diBefore = new DirectoryInfo(folder.FolderInfo.FullName); folder.FolderInfo.CreationTime = newDt; folder.FolderInfo.LastAccessTime = newDt; folder.FolderInfo.LastWriteTime = newDt; DirectoryChanged?.Invoke(diBefore, folder.FolderInfo); // Change files in this folder. foreach (var file in folder.Files) { var fiBefore = new FileInfo(file.FullName); file.CreationTime = newDt; file.LastAccessTime = newDt; file.LastWriteTime = newDt; FileChanged.Invoke(fiBefore, file); } // Change files in subfolders. foreach (var subfolder in folder.SubFolders) { RecursivelyChangeTimeStamp(subfolder, newDt); } }
private void OnDirectoryChanged() { if (DirectoryChanged != null) { DirectoryChanged.Invoke(this, EventArgs.Empty); } }
public void Search(string path, string searchPattern, bool searchSubDirectories = false) { if (searchSubDirectories) { var allDirectories = Directory.GetDirectories(path, "*.*", SearchOption.AllDirectories); var completedDirectories = 0; var totalDirectories = allDirectories.Length + 1; foreach (var directory in allDirectories) { DirectoryChanged?.Invoke(this, new SearchDirectoryArgs(directory, totalDirectories, completedDirectories++)); SearchDirectory(directory, searchPattern); } DirectoryChanged?.Invoke(this, new SearchDirectoryArgs(path, totalDirectories, completedDirectories++)); SearchDirectory(path, searchPattern); } else { SearchDirectory(path, searchPattern); } }
void IRCallbacks.DirectoryChanged() { if (_processingChangeDirectoryCommand) { DirectoryChanged?.Invoke(this, EventArgs.Empty); _processingChangeDirectoryCommand = false; } }
private async Task <T> ProcessDirectoryChanges <T>(T item) where T : FileSystemItem { var serializedDirectory = new FileSystemDirectorySerializer().Serialize(FileSystemItems.Values.Where(p => p.HasParent)); await LocalStorageRepository.SetItem(LocalStorageDirectoryFileName, serializedDirectory); DirectoryChanged?.Invoke(this, EventArgs.Empty); return(item); }
private void Watcher_Created(object sender, FileSystemEventArgs e) { watcher.EnableRaisingEvents = true; FileEvent = "New file: " + e.Name; if (!IsFileLocked(e.FullPath)) { LastWriteTime = DateTime.Now; ArchiveName = FilesDestinationDirectory + "\\" + DateTime.Now.ToShortDateString() + " - " + DateTime.Now.Hour.ToString() + "h " + DateTime.Now.Minute.ToString() + "m " + DateTime.Now.Second.ToString() + "s " + ".zip"; isChanging = false; DirectoryChanged?.Invoke(this, EventArgs.Empty); } }
public SolutionExplorerView() { InitializeComponent(); openScriptingDirectoryButton.Click += (o, e) => { if (directoryBrowserDialog.ShowDialog(this) == DialogResult.OK) { DirectoryChanged?.Invoke(this, new DirectorySelectedEventArgs(directoryBrowserDialog.SelectedPath)); } }; }
protected override void OnDoWork(DoWorkEventArgs e) { // ... while (_directories.Count != 0 || _queue.Count != 0) { _debugger.Trace(); // First, clearing queue... while (_queue.Count > 0) { // Retireving path and going level up var key = Path.GetDirectoryName(_queue.Dequeue()) + Path.DirectorySeparatorChar; // Depending on existence of key, adding or updating time if (!_directories.ContainsKey(key)) { _directories.Add(key, _unixTime.Now); } else { _directories[key] = _unixTime.Now; } } // ... var path = string.Empty; // Searching for expired row. foreach (var pair in _directories) { if (_unixTime.Difference(pair.Value + 5) > 0) { path = pair.Key; break; } } // Invoking event & removing expired row if (!string.IsNullOrEmpty(path)) { _directories.Remove(path); DirectoryChanged?.Invoke(this, new DirectoryChangedEventArgs(path)); } } }
public bool Load(string root) { root = Path.GetFullPath(root); if (!Directory.Exists(root)) { return(false); } string old_path = RootDirectory; RootDirectory = root; CurrentDirectory = ""; DirectoryWatcher.Path = RootDirectory; DirectoryWatcher.EnableRaisingEvents = true; DirectoryChanged?.Invoke(this, new WalkerEventArgs(old_path, RootDirectory)); return(true); }
protected virtual void OnDirectoryChanged(DirectoryChangedEventArgs e) { DirectoryChanged?.Invoke(this, e); }
void IRCallbacks.DirectoryChanged() { DirectoryChanged?.Invoke(this, EventArgs.Empty); }
public void RaiseDirectoryChanged(string path) { DirectoryChanged?.Invoke(this, path); }
private void OnDirectoryChanged(DirectoryChangedEventArgs e) { DirectoryChanged?.Invoke(this, e); }
/// <summary> /// Executed when search changes the current directory. /// </summary> /// <param name="directory">The directory.</param> protected virtual void OnDirectoryChanged(string directory) { DirectoryChanged?.Invoke(directory); }
private void DirectoryWatcher_Changed(object sender, EventArgs e) { var path = Path.Combine(RootDirectory, CurrentDirectory); DirectoryChanged?.Invoke(this, new WalkerEventArgs(path, path)); }
public static void CallDirectoryChanged() { DirectoryChanged?.Invoke(); }
protected virtual void OnDirectoryChanged() { DirectoryChanged?.Invoke(this, null); }