I was only going to use the FileUpload.FileBytes property, but after looking at the corresponding example in the MSDN library, I got confused in this part:
int fileLen; // Get the length of the file. fileLen = FileUpload1.PostedFile.ContentLength; // Create a byte array to hold the contents of the file. byte[] input = new byte[fileLen - 1]; input = FileUpload1.FileBytes;
(from here , I skipped a few unimportant lines)
new in this code is looking for me as food for the garbage collector without use. (Perhaps a big meal if the file is large.) Why not just write:
byte[] input = FileUpload1.FileBytes;
I'm too new to .NET and C # to be brave enough to declare this to be just an unnecessary or bad written example. Does it have any goals (perhaps a performance advantage or so)? (Also I don't understand why they subtract 1 from fileLen .)
source share