What the C# equivalent of “mklink /J”?

后端 未结 3 1835
梦毁少年i
梦毁少年i 2020-12-24 01:39

I know how to create a symbolic link in windows in a .bat script:

mklink /J  

How to do the sam

3条回答
  •  情深已故
    2020-12-24 02:00

    Another way it to use mklink. It turns out that mklink is an internal command so you need cmd.exe to call it:

    var psi=new ProcessStartInfo("cmd.exe"," /C mklink \""+link_name+"\" \""+ target_name + "\"");
    psi.CreateNoWindow = true;
    psi.UseShellExecute = false;
    Process.Start(psi).WaitForExit();
    

    You can add /J or /d etc as you need.

    ref: Run Command Prompt Commands

提交回复
热议问题