The file or folder name contains characters that are not permitted SharePoint 2013. Removing the invalid characters using Regex C#.

Was getting the below error while uploading attachment to SharePoint document library.


string pattern = "[\\~#%&*{}/:<>?|\"-]";
string replacement = " ";

Regex regEx = new Regex(pattern);

string sanitized = Regex.Replace(regEx.Replace(input, replacement), @"\s+", " ");

Helpful post

http://simplyaprogrammer.com/2008/05/importing-files-into-sharepoint.html

Hope it helps


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “The file or folder name contains characters that are not permitted SharePoint 2013. Removing the invalid characters using Regex C#.”

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s