private static string SanitizePath(string id)
{
if (String.IsNullOrWhiteSpace(id))
{
return String.Empty;
}
id = Regex.Replace(id, @"[^\w\-\\/]+", "-"); // first, allow only words, underscores, dashes, and path separators.
return id.Trim('/', '\\', '-').ToLowerInvariant(); // ensure the string does not start or end with path characters or dashes and lowercase it.
}