public void GoToRelative(String relativePath) { try { if (relativePath != "") { if (Path.HasExtension(relativePath)) { //start process } else { if (Path1[Path1.Length - 1] != '\\') { Path1 = Path1 + "\\"; } Path1 = Path1 + relativePath; ContentRepository = PathProcess.GetDirectoryContentRepository(Path1, true); } } } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void GoTo(String path) { try { if (path != "") { if (Path.HasExtension(path)) { //start process } else { Path1 = path; ContentRepository = PathProcess.GetDirectoryContentRepository(Path1, true); } } } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void RefreshDataForTreeView() { if (Path1 != null) { List <String> pathes = new List <string>(); pathes.Add(Path1); while (true) { string buf; buf = Path.GetDirectoryName(pathes[pathes.Count - 1]); if (null == buf) { break; } pathes.Add(buf); } pathes.Reverse(); ItemCollection treeItemCollection = _treeView.Items; foreach (var path in pathes) { var path1 = Path.GetFileName(path); if (path1 == "") { path1 = path; } foreach (var treeViewItem in treeItemCollection) { if (((TreeViewItem)treeViewItem).Tag is DirectoryInfo) { if (((DirectoryInfo)((TreeViewItem)treeViewItem).Tag).Name == path1) { ((TreeViewItem)treeViewItem).IsExpanded = true; treeItemCollection = ((TreeViewItem)treeViewItem).Items; break; } } else { if (((DriveInfo)((TreeViewItem)treeViewItem).Tag).Name == path1) { ((TreeViewItem)treeViewItem).IsExpanded = true; treeItemCollection = ((TreeViewItem)treeViewItem).Items; break; } } } } } else { _treeView.Items.Clear(); foreach (DriveInfo drive in PathProcess.GetDrives()) { TreeViewItem item = new TreeViewItem(); item.Tag = drive; item.Header = drive.ToString(); item.Expanded += TreeViewItemExpanded; item.Selected += TreeViewItemSelected; item.Items.Add("*"); _treeView.Items.Add(item); } } }