web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

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

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee

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


Filed under: SharePoint, SharePoint 2010, SharePoint 2013 Tagged: SharePoint, SharePoint 2010, SharePoint 2013

This was originally posted here.

Comments

*This post is locked for comments