//-----------------------------------------------------------------------
//
// This software is licensed as Microsoft Public License (Ms-PL).
//
//-----------------------------------------------------------------------
using System.IO;
using System.Text;
namespace FlickrDownloadr
{
///
/// Utility functions used for formatting and validation.
///
public static class Utility
{
///
/// Appends a space before all capital letters in a sentence, except the first character.
///
/// Enumeration or text value that is formated like "AllRightsReserved".
/// Input text with a space infront of all capital letters.
public static string AddSpaceBetweenCapitalLetters(string text)
{
StringBuilder str = new StringBuilder();
for (int i = 0; i < text.Length; i++)
{
if (i > 0 && char.IsUpper(text[i]))
{
str.Append(" ");
}
str.Append(text[i]);
}
return str.ToString();
}
///
/// Removes any illegal characters from the path. This is used to clean out any
/// special characters from the user name.
///
/// Local disk path.
/// Local disk path where illegal characters has been removed.
public static string RemoveIllegalCharacters(string path)
{
string p = path;
char[] chars = Path.GetInvalidFileNameChars();
for (int i = 0; i < chars.Length; i++)
{
p = p.Replace(chars[i], ' ');
}
return p;
}
}
}