Guest User

Untitled

a guest
Mar 23rd, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. mklink /D C:rootPublicmytextfile.txt C:rootPublicmyothertextfile.txt
  2.  
  3. 2014/07/31 11:22 <DIR> libs
  4. 2014/08/01 13:53 4,997 mobile.iml
  5. 2014/07/31 11:22 689 proguard-rules.pro
  6. 2014/09/28 10:54 <JUNCTION> res [??C:Users_____mobilesrcmainres]
  7.  
  8. static IEnumerable<Symlink> GetAllSymLinks(string workingdir)
  9. {
  10. Process converter = new Process();
  11. converter.StartInfo = new ProcessStartInfo("cmd", "/c dir /Al") { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = workingdir };
  12. string output = "";
  13. converter.OutputDataReceived += (sender, e) =>
  14. {
  15. output += e.Data + "rn";
  16. };
  17. converter.Start();
  18. converter.BeginOutputReadLine();
  19. converter.WaitForExit();
  20.  
  21. Regex regex = new Regex(@"n.*<SYMLINKD>s(.*)s[(.*)]r");
  22.  
  23. var matches = regex.Matches(output);
  24. foreach (Match match in matches)
  25. {
  26. var name = match.Groups[1].Value.Trim();
  27. var target = match.Groups[2].Value.Trim();
  28. Console.WriteLine("Symlink: " + name + " --> " + target);
  29.  
  30. yield return new Symlink() { Name = name, Target = target };
  31. }
  32. }
  33.  
  34. class Symlink
  35. {
  36. public string Name { get; set; }
  37. public string Target { get; set; }
  38. }
  39.  
  40. PS> Get-ChildItem | ? Target | Select-Object FullName, Target
  41.  
  42. FullName Target
  43. -------- ------
  44. C:rootpublicmytextfile.txt {C:rootPublicmyothertextfile.txt}
  45.  
  46. PS> (Get-Item C:rootPublicmytextfile.txt).Target
  47. C:rootPublicmyothertextfile.txt
Add Comment
Please, Sign In to add comment