Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

What is the best way to remove illegal characters from sharepoint(MOSS) filenames, foldernames, urls, etc...

Basic character removal process is not enough...

Thanks in advance SAV

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can use the SPEncode class to do what you want.

Your choices are :

SPEncode.HtmlEncode(string);
SPEncode.HtmlEncodePreserveSpaces(string);

Good luck !

See : http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.spencode_methods.aspx

share|improve this answer
    
That doesn`t remove common illegal characters which SharePoint cant eat example [ ~ # % & * { } \ : < > ? / + | " . _ ] –  SAV Oct 27 '10 at 19:20
    
RegularExpression is useful for that but...I think there is no built in method for that in SP API –  SAV Oct 27 '10 at 19:23
    
geek.hubkey.com/2008/11/… –  SAV Oct 27 '10 at 19:25
    
Found answer and method snippet exampl about the whole thing... sharepoint-insight.com/2010/06/17/… Great example and blog post about it –  SAV Oct 27 '10 at 19:32
    
It is useful for files and folders. Bu you should keep the Encode methode for the URL ! Thanks for the links, they are interesting ! –  Sébastien Levert Oct 27 '10 at 19:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.