private void ReadConfigSettings() { SetLocaleCode(); if (!SetWorkDir(GetConfigValue(ConfigConsts.WORK_DIR))) { string md5Name = CryptUtils.ComputeHash(GetConfigValue(ConfigConsts.PRODUCT_TITLE), CryptUtils.Hash.MD5); SetWorkDir(Path.Combine(KnownFolders.GetTempFolderSafe(), "Temp\\" + md5Name + "_files\\")); } }
private bool SetWorkDir(string installerWorkDir) { try { if (string.IsNullOrEmpty(workDir)) { if (string.IsNullOrEmpty(installerWorkDir)) { string mainProdName = GetConfigValue(ConfigConsts.PRODUCT_TITLE); mainProdName = string.Join(string.Empty, mainProdName.Split(Path.GetInvalidFileNameChars())); // no invalid filename characters mainProdName = mainProdName.Replace(" ", "_"); // no spaces mainProdName = mainProdName.Substring(0, Math.Min(mainProdName.Length, 15)); // max length 15 workDir = Path.Combine(KnownFolders.GetTempFolderSafe(), "Temp\\" + mainProdName + "_files\\"); } else { workDir = installerWorkDir; } if (Directory.Exists(workDir)) { #if DEBUG Logger.GetLogger().Info("workDir " + workDir + " exists already."); #endif } else { #if DEBUG Logger.GetLogger().Info("Creating working directory for installer: " + workDir); #endif Directory.CreateDirectory(workDir); } } } #if DEBUG catch (Exception e) #else catch (Exception) #endif { #if DEBUG Logger.GetLogger().Error("Creating working directory " + workDir + " failed. " + e.Message); #endif workDir = ""; } return(!string.IsNullOrEmpty(workDir)); }