I've setup a custom event receiver. The purpose of my event receiver is to stop people from uploading any file type except PDF's. Right now my code looks like this:
if (properties.AfterUrl.Substring(properties.AfterUrl.Length-4).ToLower() != ".pdf")
{
properties.Cancel = true;
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = "Adding non PDF files is not allowed.";
}
The problem is that this prevents people from adding folders, unless you make all your folder names end with .pdf :). I've considered the option of putting a check to see if the item being added contains a period, like properties.AfterUrl.Contains(".")
, however this would allow tricky people to upload files that have no extension and would disallow folder names with periods.
I did a comparison of SPItemEventProperties between WSS3 and 2010 and found that they added a property called FileSystemObjectTypePropertyName, my guess is that in 2010 this property fills the roll. For the time being though I am stuck with WSS3.
Thoughts?