private static string GetAbsolutePath(string folder, bool checkIfRooted) {
string originalFolder = folder;
if (checkIfRooted) {
folder = folder.Replace('/', Path.DirectorySeparatorChar);
folder = folder.Replace('\\', Path.DirectorySeparatorChar);
}
folder = folder.Replace("$[AssemblyFile]", Assembly.GetExecutingAssembly().Location);
folder = folder.Replace("$[AssemblyFolder]", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
folder = folder.Replace("$[ApplicationData]", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
folder = folder.Replace("$[CommonApplicationData]", Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
folder = folder.Replace("$[Personal]", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
if (checkIfRooted && !Path.IsPathRooted(folder)) {
throw new InvalidDataException("The folder " + originalFolder + " does not produce an absolute path.");
}
return folder;
}