/// <summary> /// 删除硬链接目录 /// </summary> /// <param name="linkPath"></param> public static void DeleteLink(string linkPath) { var os = Environment.OSVersion; if (os.ToString().Contains("Windows")) { ToolsHelper.ExecuteCommand(String.Format("rmdir \"{0}\"", linkPath)); } else if (os.ToString().Contains("Unix")) { ToolsHelper.ExecuteCommand(String.Format("rm -Rf \"{0}\"", linkPath)); } else { ToolsHelper.Error(String.Format("[SymbolLinkFolder]Error on OS: {0}", os.ToString())); } }
public static void SymbolLinkFolder(string srcFolderPath, string targetPath) { var os = Environment.OSVersion; if (os.ToString().Contains("Windows")) { ToolsHelper.ExecuteCommand(String.Format("mklink /J \"{0}\" \"{1}\"", targetPath, srcFolderPath)); } else if (os.ToString().Contains("Unix")) { var fullPath = Path.GetFullPath(targetPath); if (fullPath.EndsWith("/")) { fullPath = fullPath.Substring(0, fullPath.Length - 1); fullPath = Path.GetDirectoryName(fullPath); } ToolsHelper.ExecuteCommand(String.Format("ln -s {0} {1}", Path.GetFullPath(srcFolderPath), fullPath)); } else { ToolsHelper.Error(String.Format("[SymbolLinkFolder]Error on OS: {0}", os.ToString())); } }