private void ScanFolder(IList <BrowserItem> items, string relativePath) { string absolutePath = this.FileBrowser.GetAbsolutePath(relativePath); if (!Directory.Exists(absolutePath)) { return; } //add directories foreach (string childDirectory in Directory.GetDirectories(absolutePath)) { string directoryName = Path.GetFileName(childDirectory); string folderRelativePath = Path.Combine(relativePath, directoryName); if (FilterFolder(folderRelativePath)) { continue; } BrowserItem item = this.FileBrowser.CreateFolderItem(folderRelativePath); items.Add(item); } //add files foreach (string file in Directory.GetFiles(absolutePath)) { string fileName = Path.GetFileName(file); string ext = Path.GetExtension(file); if (ext.Equals(".mgcontent", StringComparison.OrdinalIgnoreCase)) { continue; } string fileRelativePath = Path.Combine(relativePath, fileName); BrowserItem item = this.FileBrowser.CreateBrowserItem(fileRelativePath); items.Add(item); } }
protected void AddItem(BrowserItem item) { if (_items == null) { _items = InitItems(); } _items.Add(item); }
protected virtual void OnWatcherCreated(FileSystemEventArgs e) { if (Directory.Exists(e.FullPath)) { string directoryName = Path.GetFileName(e.FullPath); string folderRelativePath = Path.Combine(this._relativePath, directoryName); if (!FilterFolder(folderRelativePath)) { string directoryRelativePath = Path.Combine(_relativePath, directoryName); BrowserItem item = this.FileBrowser.CreateFolderItem(directoryRelativePath); AddItem(item); } } if (File.Exists(e.FullPath)) { string fileName = Path.GetFileName(e.Name); string fileRelativePath = Path.Combine(this._relativePath, fileName); BrowserItem item = this.FileBrowser.CreateBrowserItem(fileRelativePath); AddItem(item); } }