string GetMediaPortalDir(string path)
{
string CommonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
// Replace special folder variables if they exist
// MediaPortal currently only uses two types
path = path.ToLower();
path = path.Replace("%appdata%", AppData);
path = path.Replace("%programdata%", CommonAppData);
// Check if the path is not rooted ie. a custom directory (including UNC)
// If directory is relative e.g. 'skin\', prefix with Base Dir
if (!Path.IsPathRooted(path))
{
path = Path.Combine(SkinInfo.mpPaths.sMPbaseDir, path);
}
// Check if there is a trailing backslash
if (!path.EndsWith(@"\"))
{
path += @"\";
}
return path;
}