I was using blank text files to run some tests, and was going crazy because FileUpload1.HasFile was always coming back false, even though it clearly had a file. I then switched test files to something above 0 kb (i.e. txt files with text in them), and then it worked.
As far as I can tell, you can't upload something of 0 kb. Is this true? I read about the FileUpload class on MSDN, but didn't notice anything that says files of 0 kb would be ignored/treated as not a file.
Realistically and practically, I don't see this as being much of a problem (why would you want to upload a blank file?), but I can imagine some kind of rare situation where I might want to reserve a space for something that doesn't have content yet, like a blank text file for a user to fill in when he/she has time.
you can use FileUpload.PostedFile Property
, that will give you access to the file even if the content is 0
bytes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With