I have an input type file in my .aspx page.
<input type="file" id="BatchImportFile" runat="server">
When I am trying to check the File.PostedFile.ContentLength
property for an empty file it is always showing value as 2 even if I upload an empty file.
I want to check an empty .csv
file .
The file that you uploaded simply was not empty. 2 bytes is the length of a Windows line terminator. Maybe it contains an empty line. Unicode BOM headers are also 2 bytes in length.
Use String.IsNullOrWhiteSpace
to check for this case.