/// <summary> /// Gets the physical path. /// </summary> /// <returns>The physical path.</returns> /// <param name="path">Path.</param> public string GetPhysicalPath(string path) { // Security Vulnerability, ".." is interpreted as parent directory here! if (!HostDirectory.EndsWith("/")) { HostDirectory = HostDirectory + "/"; } return(HostDirectory + path); }
/// <summary> /// Получить путь к системному каталогу. Так как разных средах исполнения они разные, наверное проще так. /// </summary> /// <param name="hostDirectory">Предопределённый системный каталог</param> /// <returns></returns> public static string GetDirectory(HostDirectory hostDirectory) { switch(hostDirectory) { case HostDirectory.Tmp: if (GetOS() == OSPlatform.Windows) { return GetVariable("TMP"); } else if(GetOS() == OSPlatform.Linux) { return @"/var/tmp"; } break; default: throw new ArgumentException(); } return null; }