OT: Why doesn't System.IO.File have a GetSize method?

  • Thread starter Thread starter Harlan Messinger
  • Start date Start date
H

Harlan Messinger

System.IO.File has methods like GetCreationTime, GetLastWriteTime,
GetAttributes, and GetAccessControl. Why is GetSize missing?
 
Hello,

This is provided by FileInfo.Length.

If you meant that beyond knowing how to get the info, you really want to
know why it is not provided by IO.File, only MS could perhaps answer if done
on purpose (such as a low level difference between getting the dates and the
size).
 
Patrice said:
Hello,

This is provided by FileInfo.Length.

If you meant that beyond knowing how to get the info, you really want to
know why it is not provided by IO.File, only MS could perhaps answer if done
on purpose (such as a low level difference between getting the dates and the
size).

Yes, that's what I was getting at. However, it's possible that MS has
explained it and there are non-MS people out there--even in this
newsgroup, perhaps--who know the answer!
 
Yes, that's what I was getting at. However, it's possible that MS has
explained it and there are non-MS people out there--even in this
newsgroup, perhaps--who know the answer!

Possible but seems quite unlikely you'll find such a low level design
decision. Not even sure it has a real reason. I've just seen that the doc
suggest to use FileInfo if you use the same file over and over as File does
a security check for each method.

I gave a qucik look at the MFT but according to wikipeida both dates and
sizes are stored in the MFT. Not sure if getting the dates /size on a locked
file would make a difference...
 
I'm trying to determine myself if there is a method in a class that allows
me to determine the number of bytes in a file without loading the file which
could be very large such as a 25MB video file.

Does File.Length property support doing so?
 
Yes, that's what I was getting at. However, it's possible that MS has
explained it and there are non-MS people out there--even in this
newsgroup, perhaps--who know the answer!

I don't think you should expect that all names are the result
of a very deep thinking process.

Names just get picked and when they have been publicised,
then the users are stuck with them forever.

Look at it this way. .NET 3.5 has about 300000 public names.
If we say that it takes a meeting of 5 people 1 hour to really
discuss possible names and agree on the best one, then it would
have had cost MS 300000*5 hours*200 USD/hour = 300 million USD
to come up with better names. Would use 300 million have been
wisely spent? I don't think so!

Arne
 
Back
Top