SPFile Upload Invalid Characters
Kirk Hofer

Microsoft Dynamics Vertical

Inetium can implement a CRM solution that fits your business needs.

Learn More >>

Inetium is the go to partner for Microsoft SharePoint consulting services.

Learn more >>

Syndication

If you are like me and have uploaded a bunch of files to SharePoint then you have had the weird character issue.  Use this Regex to clean it.  This can be tweaked to run in PowerShell as well... 

////\/:*?"<>|#{}%~&

public static string CleanSPFileName(string fileName)
{

    return System.Text.RegularExpressions.Regex.Replace(fileName, "(\\?|\\:|\\~|\\#|\\{|\\}|\\&|%|[|]|\\*|\\?|\\\\|\\/|\\<|\\>|\"+)+", "");

}


Posted 05-07-2008 9:11 PM by khofer
Filed under:
Inetium, LLC. Site Information