Here is my code. It works but also throws following error.
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
if (ValidFile(properties) == false)
{
properties.ErrorMessage = "File size cannot be greater than 1MB";
properties.Cancel = true;
}
}
Server Error in '/' Application.
0x81020089File size cannot be greater than 1MB Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: 0x81020089File size cannot be greater than 1MB
Source Error: