Tal vez alguien está interesado en un método de C# para resolver todos los enlaces simbólicos de directorio en un directorio similar a Directory.GetDirectories(). Para enumerar uniones o enlaces simbólicos de archivos, simplemente cambie la expresión regular.
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 + "\r\n";
};
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; }
}
o si es posible ¿cómo perseguir el enlace en Perl –
Es un poco extraño tener un directorio llamado MyTextFile.txt; ¿Estás seguro de que quisiste usar la opción/D? –
De todos modos, el comando "dir" muestra el destino de enlaces simbólicos por defecto. –