in

Kirk Hofer

SPFile Upload Invalid Characters

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, "(\\?|\\:|\\~|\\#|\\{|\\}|\\&|%|[|]|\\*|\\?|\\\\|\\/|\\<|\\>|\"+)+", "");

}

Only published comments... May 07 2008, 09:11 PM by khofer
Filed under:

Leave a Comment

(required)  
(optional)
(required)  
Add
Inetium, LLC. Disclaimer