private static void TraverseDirectory(object fillOut) { lock (fillOut) { CFillerThreadParam param = fillOut as CFillerThreadParam; CDirectoryEntry fill = param.rootEntry; if (fill != null) { DirectoryInfo info = new DirectoryInfo(fill.FullPath); TraverseInternal(info, ref fill.SubEntries); } param.callBack(fill); } }
public static void PopulateTreeView(string sRootPath) { if (!Directory.Exists(sRootPath)) { var empty = new DirectoryTreeItem(); empty.Header = "Specified path doesn't exist!"; // LOCALIZE m_targetTreeView.Items.Clear(); m_targetTreeView.Items.Add(empty); return; } DirectoryInfo dirInfo = new DirectoryInfo(sRootPath); DirectoryTreeItem item = new DirectoryTreeItem(); /*item.SetName(dirInfo.Name); * item.FullPath = dirInfo.FullName; * item.IsDirectory = true; * * item.ContextMenu = m_viewItemContextMenu; * * //item.MouseRightButtonDown += delegate { item.IsSelected = true; }; * * * TraverseDirectory(dirInfo, ref item); * * m_targetTreeView.Items.Add(item);*/ if (sRootPath == m_sDirectoryToWatch) { m_lastSelectedItem = m_targetTreeView.SelectedItem as DirectoryTreeItem; } else { m_lastSelectedItem = null; } m_bFillFinished = false; CDirectoryEntry rootEntry = new CDirectoryEntry(); rootEntry.Header = dirInfo.Name; rootEntry.FullPath = dirInfo.FullName; rootEntry.IsDirectory = true; CFillerThreadParam param = new CFillerThreadParam(); param.rootEntry = rootEntry; param.callBack = FillerCallback; m_timer.Start(); m_targetTreeView.Items.Clear(); item.Header = "Loading"; m_targetTreeView.Items.Add(item); Thread filler = new Thread(TraverseDirectory); filler.Start(param as object); }