Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mklink /D C:rootPublicmytextfile.txt C:rootPublicmyothertextfile.txt
- 2014/07/31 11:22 <DIR> libs
- 2014/08/01 13:53 4,997 mobile.iml
- 2014/07/31 11:22 689 proguard-rules.pro
- 2014/09/28 10:54 <JUNCTION> res [??C:Users_____mobilesrcmainres]
- static IEnumerable<Symlink> GetAllSymLinks(string workingdir)
- {
- Process converter = new Process();
- converter.StartInfo = new ProcessStartInfo("cmd", "/c dir /Al") { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = workingdir };
- string output = "";
- converter.OutputDataReceived += (sender, e) =>
- {
- output += e.Data + "rn";
- };
- converter.Start();
- converter.BeginOutputReadLine();
- converter.WaitForExit();
- Regex regex = new Regex(@"n.*<SYMLINKD>s(.*)s[(.*)]r");
- var matches = regex.Matches(output);
- foreach (Match match in matches)
- {
- var name = match.Groups[1].Value.Trim();
- var target = match.Groups[2].Value.Trim();
- Console.WriteLine("Symlink: " + name + " --> " + target);
- yield return new Symlink() { Name = name, Target = target };
- }
- }
- class Symlink
- {
- public string Name { get; set; }
- public string Target { get; set; }
- }
- PS> Get-ChildItem | ? Target | Select-Object FullName, Target
- FullName Target
- -------- ------
- C:rootpublicmytextfile.txt {C:rootPublicmyothertextfile.txt}
- PS> (Get-Item C:rootPublicmytextfile.txt).Target
- C:rootPublicmyothertextfile.txt
Add Comment
Please, Sign In to add comment