目录符号链接和目录联接(看原文即目录的硬链接)的区别在于:
目录联接在创建时会自动引用目标目录的绝对路径,而符号链接允许相对路径的引用。
如分别用 mklink /D dira tdir 和 mklink /J dirb tdir 创建 dira、dirb 对 tdir 的符号链接和目录联接,之后将 dira、dirb 移动到其它目录下,则访问 dira 时会提示“位置不可用”,访问 dirb 时仍然正常指向 tdir;
而分别用 mklink /D dira c:\demo\tdir 和 mklink /J dirb c:\demo\tdir 创建 c:\demo\tdir 的符号链接和目录联接,再将这两个目录链接移动到其它目录下,则 dira 和 dirb 均可正常指向 c:\demo\tdir;
由此可见当创建目录链接时对目标目录使用绝对路径,D 和 J 两个参数实现的目录链接效果是一样的;
英文原文:
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file symbolic link. /H Creates a hard link instead of a symbolic link. /J Creates a Directory Junction.
/D creates a symbolic link, or a soft link.This essentially acts like a shortcut to a folder in prior versions of Windows, except you don’t have to use an actual shortcut.
/H creates a hard link, which points directly to the file.This option can’t be used for folders directly for some reason, you’ll have to use the next option.
/J creates a “Directory
目录联接在创建时会自动引用目标目录的绝对路径,而符号链接允许相对路径的引用。
如分别用 mklink /D dira tdir 和 mklink /J dirb tdir 创建 dira、dirb 对 tdir 的符号链接和目录联接,之后将 dira、dirb 移动到其它目录下,则访问 dira 时会提示“位置不可用”,访问 dirb 时仍然正常指向 tdir;
而分别用 mklink /D dira c:\demo\tdir 和 mklink /J dirb c:\demo\tdir 创建 c:\demo\tdir 的符号链接和目录联接,再将这两个目录链接移动到其它目录下,则 dira 和 dirb 均可正常指向 c:\demo\tdir;
由此可见当创建目录链接时对目标目录使用绝对路径,D 和 J 两个参数实现的目录链接效果是一样的;
英文原文:
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file symbolic link. /H Creates a hard link instead of a symbolic link. /J Creates a Directory Junction.
/D creates a symbolic link, or a soft link.This essentially acts like a shortcut to a folder in prior versions of Windows, except you don’t have to use an actual shortcut.
/H creates a hard link, which points directly to the file.This option can’t be used for folders directly for some reason, you’ll have to use the next option.
/J creates a “Directory
