Пример #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 private void fillNode(TreeNode node)
 {
     node.Nodes.Clear();
     string fullpath = "";
     TreeNode nextNode = node;
     // Build the full path by working our way up the tree adding each node's text to the full path.
     // If we're using targets and we hit a reparse point, put the RPs target on the front and stop looping
     do
     {
         if (targetRadioButton.Checked &&
             nextNode.Tag != null &&
             ((ReparsePoint)nextNode.Tag).Tag != ReparsePoint.TagType.None &&
             ((ReparsePoint)nextNode.Tag).Tag != ReparsePoint.TagType.MountPoint)	// Don;t trya and access mountpoints by target
         {
             // access the folder via its target rather than its actual name (this is the only way under XP)
             fullpath = ((ReparsePoint)nextNode.Tag).ToString() + "\\" + fullpath;
             break;
         }
         else
         {
             fullpath = nextNode.Text + "\\" + fullpath;
             nextNode = nextNode.Parent;
         }
     } while (nextNode != null);
     try
     {
         foreach (string directory in Directory.GetDirectories(fullpath))
         {
             ReparsePoint reparsePoint = new ReparsePoint(directory);
             TreeNode newNode = node.Nodes.Add(directory.Substring(directory.LastIndexOf('\\') + 1));
             newNode.Tag = reparsePoint;
             if (reparsePoint.Tag == ReparsePoint.TagType.MountPoint)
             {
                 newNode.ForeColor = Color.Red;
             }
             else if (reparsePoint.Tag == ReparsePoint.TagType.JunctionPoint)
             {
                 newNode.ForeColor = Color.Blue;
             }
             if (reparsePoint.Tag == ReparsePoint.TagType.SymbolicLink)
             {
                 newNode.ForeColor = Color.Green;
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, exception.GetType().ToString());
     }
     node.Expand();
 }
Пример #2
0
 /// <summary>
 /// Determines whether the specified path is a Junction Point
 /// </summary>
 /// <param name="path">The path to check</param>
 public static bool IsJunctionPoint(string path)
 {
     ReparsePoint p = new ReparsePoint(path);
     return (p.Tag == ReparsePoint.TagType.JunctionPoint);
 }
Пример #3
0
 /// <summary>
 /// Determines whether the specified path is a symbolic link
 /// </summary>
 /// <param name="path">The path to check</param>
 public static bool IsSymbolicLink(string path)
 {
     if (File.Exists(path) || Directory.Exists(path))
     {
         ReparsePoint p = new ReparsePoint(path);
         return (p.Tag == ReparsePoint.TagType.SymbolicLink);
     }
     else
     {
         throw new DirectoryNotFoundException(String.Format("The item at '{0}' could not be found", path));
     }
 }
Пример #4
0
 /// <summary>
 /// Gets the target of a Symbloic Link or Junction Point
 /// </summary>
 /// <param name="path">The path of the Symbolic link or Junction Point</param>
 /// <returns>Returns the path the Reparse Point points to</returns>
 public static string GetLinkTarget(string path)
 {
     ReparsePoint p = new ReparsePoint(path);
     return p.Target;
 }