IoHelperCreateSymbolicLink 方法

创建符号链接(软链接) 需要管理员权限或 Windows 开发者模式 符号链接类似于快捷方式,但对应用程序透明

Definition

命名空间: Suresking.Utility
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
C#
public static ResultStatus CreateSymbolicLink(
	string sourcePath,
	string linkPath,
	bool isDirectory = false
)

参数

sourcePath  String
链接指向的源路径(文件或目录)
linkPath  String
要创建的链接路径
isDirectory  Boolean  (Optional)
是否为目录创建链接,默认为 false(文件链接)

返回值

ResultStatus
包含操作结果的 ResultStatus

备注

Windows 要求: - 管理员权限 或 启用开发者模式 - 目标路径不存在 Linux/Mac 要求: - 文件系统支持符号链接

示例

// 创建目录链接 IoHelper.CreateSymbolicLink(@"D:\Shared\Data", @"C:\App\Data", isDirectory: true);

参见