public void ShowFolder(string directoryPath)
{
if ((directoryPath == null) || (directoryPath == "") || (directoryPath == string.Empty)) return;
bool requestNetwork = directoryPath.StartsWith(@"\\") ? true : false;
// start search at root node
TreeNodeCollection nodeCol = _dataProvider.RequestDriveCollection(_helper, requestNetwork);
//
if (!Directory.Exists(directoryPath) || nodeCol == null) return;
//
DirectoryInfo dirInfo = new DirectoryInfo(directoryPath);
// get path tokens
ArrayList dirs = new ArrayList();
dirs.Add(dirInfo.FullName);
//
while (dirInfo.Parent != null)
{
dirs.Add(dirInfo.Parent.FullName);
//
dirInfo = dirInfo.Parent;
}
// For network we should add also the server tp the dir list
if (requestNetwork)
{
dirs.Add(dirInfo.FullName.Substring(0, dirInfo.FullName.LastIndexOf(@"\")));
}
// try to expand all path tokens
Cursor.Current = Cursors.WaitCursor;
BeginUpdate();
// load on demand was not fired till now
if (nodeCol.Count == 1 && ((TreeNodePath)nodeCol[0]).Path == null)
{
nodeCol[0].Parent.Expand();
}
try
{
//
for (int i = dirs.Count - 1; i >= 0; i--)
{
foreach (TreeNodePath n in nodeCol)
{
if (n.Path.ToLower().CompareTo(dirs[i].ToString().ToLower()) == 0)
{
nodeCol = n.Nodes;
if (i == 0)
{
n.EnsureVisible();
SelectedNode = n;
}
else
{
n.Expand();
}
break;
}
}
}
}
catch (Exception e)
{
throw e;
}
finally
{
EndUpdate();
Cursor.Current = Cursors.Default;
}
}