Validating the size of a Uploaded File
Most often, in our websites, we will be required to validate the end user's uploaded file size. This is how to do it.
1. Add the File upload control to the aspx page
< asp:FileUpload ID="objFileUpload" runat="server" ToolTip="UpLoad Your Files" Width="230px" />
2. In the web.config, specify the maximum valid file size in KB
< appSettings>
< add key="MaxFileSize" value="10240"/>
</appSettings>
3. In the file upload page, get the MaxFileSize in a double variable
double dblMaxFileSize = Convert.ToDouble(ConfigurationManager.AppSettings["MaxFileSize"]);
4. Get the size of the file.
int intFileSize = fupIcon.PostedFile.ContentLength; // Here the file size is obtained in bytes
double dblFileSizeinKB = intFileSize / 1024.0; // We convert the file size into kilobytes
5. Check if the uploaded file size is greater than the set Max limit
if ((dblFileSizeinKB > dblMaxFileSize ))
{
lblMsg.Text = "File Size Should be less than" + dblMaxFileSize.ToString() + " KB";
return;
}

Please format your resource.