views:

395

answers:

2

Hi, I noticed that every time I try to attach a file to a SharePoint list, if the file name contains any special characters (#, &, @, ...) it will not go through. Will not be attached and will cause an error. Is there any way around that? Thanks,

+2  A: 

You can create an "event receiver" (see SPItemEventReceiver class on msdn) that will watch for the ItemAttaching event which occurs before the item is attached. This will let you replace the invalid characters with legal replacements.

Bear in mind that if you replace all invalid chars with the same one - "_" for example - the onus is on you to avoid name collisions.

-Oisin

x0n
+1  A: 

Rename your files first? These characters are not banned because SharePoint is fussy but because they mean something in the url adressible world; it makes sense not to use ? and / etc. in your filenames because they are reserved characters in urls.

ArjanP