using System; using System.IO; namespace Update.Util { /// /// 文件路径工具 /// public static class FilePathUtil { //基目录,格式:C:\WorkDir private static readonly string m_BaseDirectory = AppDomain.CurrentDomain.BaseDirectory; /// /// 获取绝对路径所在目录 /// /// 绝对路径 /// 所在目录 public static string GetDirectoryName(string absolutePath) { return Path.GetDirectoryName(absolutePath); } /// /// 获取文件的绝对路径(相对于当前基目录) /// /// 相对路径 /// 绝对路径 public static string GetAbsolutePath(string relativePath) { return GetAbsolutePath(relativePath, m_BaseDirectory); } /// /// 获取文件的绝对路径 /// /// 相对路径 /// 基路径 /// 绝对路径 public static string GetAbsolutePath(string relativePath, string basePath) { return Path.Combine(basePath, relativePath).Replace('/', '\\'); } } }