SafeSubstring
Description: Safely gets a substring of a given length from a string, without causing an out-of-bounds exception.
Signaturepublic static string SafeSubstring(string input, int maxLength)
IsAbsoluteUrl
Description: Checks if a given URL is an absolute URL.
Signaturepublic static bool IsAbsoluteUrl(string url)
RemoveDiacritics
Description: Removes diacritics (accents) from a string.
Signaturepublic static string RemoveDiacritics(string text)
DeCode
Description: Decodes a string that was encoded by converting each character to its integer value, separated by dots.
Signaturepublic static string DeCode(string codedval)
EnCode
Description: Encodes a string by converting each character to its integer value, separated by dots.
Signaturepublic static string EnCode(string value)
DecodeCSV
Description: Decodes a comma-separated string where each value was encoded using the EnCode method.
Signaturepublic static string DecodeCSV(string inputData)
CreateFolder
Description: Creates a folder if it does not already exist.
Signaturepublic static void CreateFolder(string folderMapPath)
DeleteFolder
Description: Deletes a folder.
Signaturepublic static void DeleteFolder(string folderMapPath, bool recursive = false)
FormatToSave
Description: Formats a string for saving, applying scripting protection.
Signaturepublic static string FormatToSave(string inpData)
FormatToSave
Description: Formats a string for saving based on its data type, applying scripting protection.
Signaturepublic static string FormatToSave(string inpData, TypeCode dataTyp)
FormatDisableScripting
Description: Removes potentially malicious HTML tags and scripts from a string to prevent XSS attacks.
Signaturepublic static string FormatDisableScripting(string strInput, bool filterlinks = true)
FormatToSave
Description: Formats data for saving to XML, converting it to a culture-invariant format.
Signaturepublic static string FormatToSave(string inpData, TypeCode dataTyp, string editlang)
IsCultureInfo
Description: Checks if a given string is a valid culture code.
Signaturepublic static bool IsCultureInfo(string cultureCode)
FormatToDisplay
Description: Formats data for display, converting it from a culture-invariant format to a culture-specific format.
Signaturepublic static string FormatToDisplay(string inpData, string cultureCode, TypeCode dataTyp, string formatCode = "")
FormatDateToString
Description: Formats a DateTime object into a string based on a specific culture.
Signaturepublic static string FormatDateToString(DateTime dateTime, string cultureCode)
IsEmail
Description: Checks if a string is a valid email address.
Signaturepublic static bool IsEmail(string emailaddress)
IsNumeric
Description: Checks if an object can be converted to a numeric value, optionally using a specific culture.
Signaturepublic static bool IsNumeric(object expression, string cultureCode = "")
IsUriValid
Description: Checks if a string is a well-formed URI and can optionally check if the host exists.
Signaturepublic static bool IsUriValid(string uri, UriKind uriKind = UriKind.RelativeOrAbsolute, bool checkexists = false)
IsDate
Description: Checks if an object can be converted to a DateTime value using a specific culture.
Signaturepublic static bool IsDate(object expression, string cultureCode)
IsDateInvariantCulture
Description: Checks if an object can be converted to a DateTime value using a set of common invariant culture formats.
Signaturepublic static bool IsDateInvariantCulture(object expression)
FormatAsMailTo
Description: Creates a 'mailto' link that is obfuscated to protect the email address from scrapers.
Signaturepublic static string FormatAsMailTo(string email, string subject = "", string visibleText = "")
DeleteSysFile
Description: Deletes a file, ignoring any exceptions if the file is locked.
Signaturepublic static void DeleteSysFile(string filePathName)
CleanInput
Description: Strips out characters from a string that do not match a given regular expression.
Signaturepublic static string CleanInput(string strIn, string regexpr = "")
AlphaNumeric
Description: Strips out all non-alphanumeric characters from a string.
Signaturepublic static string AlphaNumeric(string strIn)
Numeric
Description: Strips out all non-numeric characters from a string.
Signaturepublic static string Numeric(string strIn)
UrlFriendly
Description: Converts a string into a URL-friendly format (e.g., 'like-this-one').
Signaturepublic static string UrlFriendly(string title)
SanitizeFileName
Description: Sanitizes a file name by removing diacritics and invalid file name characters.
Signaturepublic static string SanitizeFileName(string fileName)
RemapInternationalCharToAscii
Description: Remaps common international characters to their ASCII equivalents.
Signaturepublic static string RemapInternationalCharToAscii(char c)
StripAccents
Description: Strips accents from a string.
Signaturepublic static string StripAccents(string s)
GetUniqueString
Description: Generates a highly unique, URL-safe string based on the current time and a random number.
Signaturepublic static string GetUniqueString(int randomsize = 8)
GetRandomKey
Description: Generates a random string of a specified size. Not guaranteed to be unique.
Signaturepublic static string GetRandomKey(int maxSize = 0, bool numericOnly = false)
GetGuidKey
Description: Generates a URL-safe key from a new GUID.
Signaturepublic static string GetGuidKey()
ReplaceFirstOccurrence
Description: Replaces the first occurrence of a substring within a string.
Signaturepublic static string ReplaceFirstOccurrence(string source, string find, string replace)
ReplaceLastOccurrence
Description: Replaces the last occurrence of a substring within a string.
Signaturepublic static string ReplaceLastOccurrence(string source, string find, string replace)
Decrypt
Description: Decrypts a string using DES encryption with a given key.
Signaturepublic static string Decrypt(string strKey, string strData)
Encrypt
Description: Encrypts a string using DES encryption with a given key.
Signaturepublic static string Encrypt(string strKey, string strData)
ReplaceFileExt
Description: Replaces the extension of a file path with a new extension.
Signaturepublic static string ReplaceFileExt(string fileName, string newExt)
StrToByteArray
Description: Converts a string to a byte array using UTF8 encoding.
Signaturepublic static byte[] StrToByteArray(string str)
ObjectToByteArray
Description: Serializes an object into a byte array.
Signaturepublic static byte[] ObjectToByteArray(Object obj)
CopyAll
Description: Recursively copies all files and subdirectories from a source to a target directory.
Signaturepublic static void CopyAll(string source, string target)
CopyAll
Description: Recursively copies all files and subdirectories from a source to a target directory.
Signaturepublic static void CopyAll(DirectoryInfo source, DirectoryInfo target)
GetMd5Hash
Description: Computes the MD5 hash of a string.
Signaturepublic static string GetMd5Hash(string input)
GetMd5Hash
Description: Computes the MD5 hash of a string, with an option for uppercase or lowercase output.
Signaturepublic static string GetMd5Hash(string input, bool uppercase)
Base64Encode
Description: Encodes a string into Base64 format.
Signaturepublic static string Base64Encode(string plainText)
Base64Decode
Description: Decodes a Base64-encoded string.
Signaturepublic static string Base64Decode(string base64EncodedData)
AddJsonNetRootAttribute
Description: Adds the Json.NET namespace attribute to the root element of a SimplisityInfo's XML document.
Signaturepublic static void AddJsonNetRootAttribute(ref SimplisityInfo sInfo)
AddJsonArrayAttributesForXPath
Description: Adds the Json.NET 'Array=true' attribute to all XML elements matching an XPath expression.
Signaturepublic static void AddJsonArrayAttributesForXPath(string xpath, ref SimplisityInfo sInfo)
CopyDirectory
Description: Copies a directory and its contents to a new location.
Signaturepublic static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
HtmlToPlainText
Description: Converts an HTML string to plain text by stripping out tags.
Signaturepublic static string HtmlToPlainText(string html)
EscapeJsonString
Description: Escapes special characters in a string to make it safe for inclusion in a JSON string.
Signaturepublic static string EscapeJsonString(string value)