Home All Groups Group Topic Archive Search About
Author
20 Nov 2007 11:00 PM
Jim Madsen
How do you get the "file size on disk" for a file (as opposed to the
file size (length))?

Author
21 Nov 2007 6:18 AM
Cor Ligthert[MVP]
Jim,

What is the size of a file, it has only a start point and an end point so
that gives the length in bytes, I did not know that it had more measuring
points.

However, the documentation tells that the fileinfo.length gives back

http://msdn2.microsoft.com/en-us/library/system.io.fileinfo.length(VS.71).aspx
The size of the current file. (Although size is in my idea not the best
description, probably because of the many different meanings of the word
"size" in English, while there is probably not a better word in English for
that)

Cor
Author
21 Nov 2007 2:15 PM
Jim Madsen
Well, when you right click on a file and select properties, it gives you
file size, and file size on disk, which is a little bit more.  I assume
since Windows spits out these values, there must be an API to get these
values, in worst case.

Jim

Cor Ligthert[MVP] wrote:
Show quoteHide quote
> Jim,
>
> What is the size of a file, it has only a start point and an end point
> so that gives the length in bytes, I did not know that it had more
> measuring points.
>
> However, the documentation tells that the fileinfo.length gives back
>
> http://msdn2.microsoft.com/en-us/library/system.io.fileinfo.length(VS.71).aspx
>
> The size of the current file. (Although size is in my idea not the best
> description, probably because of the many different meanings of the word
> "size" in English, while there is probably not a better word in English
> for that)
>
> Cor
>
>
>
Author
21 Nov 2007 5:24 PM
Cor Ligthert[MVP]
Jim,

Have a look at the answer from Andrew, however you make me curious, what is
the reason that you want this?

Cor

Show quoteHide quote
"Jim Madsen" <jus***@nobody.com> schreef in bericht
news:OSLt1jELIHA.4584@TK2MSFTNGP03.phx.gbl...
> Well, when you right click on a file and select properties, it gives you
> file size, and file size on disk, which is a little bit more.  I assume
> since Windows spits out these values, there must be an API to get these
> values, in worst case.
>
> Jim
>
> Cor Ligthert[MVP] wrote:
>> Jim,
>>
>> What is the size of a file, it has only a start point and an end point so
>> that gives the length in bytes, I did not know that it had more measuring
>> points.
>>
>> However, the documentation tells that the fileinfo.length gives back
>>
>> http://msdn2.microsoft.com/en-us/library/system.io.fileinfo.length(VS.71).aspx
>> The size of the current file. (Although size is in my idea not the best
>> description, probably because of the many different meanings of the word
>> "size" in English, while there is probably not a better word in English
>> for that)
>>
>> Cor
>>
>>
Author
22 Nov 2007 1:03 AM
Jim Madsen
As a learning exercise for myself with vbdotnet, I am writing a program
for my daughter.  The requirement is to look for files with three
different file extensions, and group the files with the same name
together.  It needs to create subdirectories, copy files with these
extensions to the subdirectories, so that each subdirectory holds just
under the maximum amount that can be copied to a DVD.  And if there
isn't room for a group of 3 files, it needs to be copied to the next
subdirectory, rather than just have one or two of the files on the first
subdirectory.

Jim

Cor Ligthert[MVP] wrote:
Show quoteHide quote
> Jim,
>
> Have a look at the answer from Andrew, however you make me curious, what
> is the reason that you want this?
>
> Cor
Author
22 Nov 2007 5:45 AM
Cor Ligthert[MVP]
Jim,

Then you have in my idea to calculate how long it will be in bytes in the
target area.

The same again using the method as Andrew wrote using the length and then
the (rounded) size it will then have on the target, I think you have to
learn a lot from it, wmi is very interresting to do, and right in your goal.

There is enough written in this newsgroup about that.

http://groups.google.com/group/microsoft.public.dotnet.languages.vb/search?hl=en&group=microsoft.public.dotnet.languages.vb&q=wmi&qt_g=Search+this+group


Cor
Author
22 Nov 2007 9:56 AM
Andrew Morton
Jim Madsen wrote:
> As a learning exercise for myself with vbdotnet, I am writing a
> program for my daughter.  The requirement is to look for files with
> three different file extensions, and group the files with the same
> name together.  It needs to create subdirectories, copy files with
> these extensions to the subdirectories, so that each subdirectory
> holds just under the maximum amount that can be copied to a DVD.  And
> if there isn't room for a group of 3 files, it needs to be copied to
> the next subdirectory, rather than just have one or two of the files
> on the first subdirectory.

So you need to find the cluster size for the particular DVD format you want
to write to (DVD-RAM/DVD-R etc), and remember that not quite all the space
is available for data.

If you're filling it to the brim, you may want to zip the files using, e.g.
SharpZipLib
http://www.icsharpcode.net/OpenSource/SharpZipLib/

(Hint: if you use that, make sure to set the .Size of each Entry or else
Windows won't understand the zip file.)

Andrew
Author
21 Nov 2007 9:09 AM
Andrew Morton
Jim Madsen wrote:
> How do you get the "file size on disk" for a file (as opposed to the
> file size (length))?

Round up the file size to the nearest multiple of the size of an allocation
unit (cluster). Now the problem is to find the size of an allocation unit,
which I guess should be available through WMI.

Andrew
Author
26 Nov 2007 9:21 AM
Eternal Snow
Have we lost some?
What about the compressed file. I means, the file with "compress" property
checked.

Show quoteHide quote
"Jim Madsen" <jus***@nobody.com> wrote in message
news:eSqKjk8KIHA.5860@TK2MSFTNGP04.phx.gbl...
> How do you get the "file size on disk" for a file (as opposed to the file
> size (length))?