|
From: Lorin on 21 Jun 2008 10:18 VB6 How do I get a file's "size on disk"? (not file size)
From: christery on 21 Jun 2008 10:45 On 21 Juni, 16:18, "Lorin" <lor...(a)hotmail.com> wrote: > VB6 > How do I get a file's "size on disk"? > (not file size) Ehh, dont understand the Q, but round it up to the nearest sector size, as a 0 yet still uses one sector (or thats what i figured out) Or is the MB a problem look at http://www.webopedia.com/quick_ref/FileSizeConversionTable.asp //CY
From: Lorin on 21 Jun 2008 11:37 Yes, it is the relationship to the "physical" disk allocation that I do not understand. I read somewhere that cluster size was important, but somewhere else that sector size was too. Not sure how to work it out. For example, if I took two files reporting a size of 1 byte each and mashed them together into one file, I would use less disk space, right? So, how much disk space before and after this operation would there be? If I create a text file with only and 'A' (no quotes) in it, my Vista system reports 1K. Is that a sector? Is that the size of the file on disk? i.e. the space eaten up on the disk? So in my example, two files with 'A' in them using 104 bytes each would result in a file with 'AA' taking up only 1024 bytes. How do I calculate the real (space used) size of a file for any disk or pen drive etc? <christery(a)gmail.com> wrote in message news:9d106695-8608-4e46-81a4-cb8019eaef54(a)34g2000hsf.googlegroups.com... > On 21 Juni, 16:18, "Lorin" <lor...(a)hotmail.com> wrote: >> VB6 >> How do I get a file's "size on disk"? >> (not file size) > > Ehh, dont understand the Q, but round it up to the nearest sector > size, as a 0 yet still uses one sector (or thats what i figured out) > > Or is the MB a problem look at > http://www.webopedia.com/quick_ref/FileSizeConversionTable.asp > > //CY
From: dpb on 21 Jun 2008 12:46 Lorin wrote: > Yes, it is the relationship to the "physical" disk allocation that I do > not understand. .... The IOCTL_DISK_GET_DRIVE_GEOMETRY DeviceIoControl operation returns information about the physical disk's geometry: type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector. BOOL DeviceIoControl( (HANDLE) hDevice, // handle to device of interest IOCTL_DISK_GET_DRIVE_GEOMETRY, // dwIoControlCode, control code of // operation to perform NULL, // lpInBuffer is not used; must be NULL 0, // nInBufferSize is not used; must be zero (LPVOID) lpOutBuffer, // pointer to output buffer (DWORD) nOutBufferSize, // size, in bytes, of lpOutBuffer (LPDWORD) lpBytesReturned, // pointer to variable to receive // output byte count (LPOVERLAPPED) lpOverlapped // pointer to OVERLAPPED structure // for asynchronous operation ); Whether it functions for other than fixed media I'm not sure...there may be specific APIs for them; I've never fooled w/ them lower than at the user program level. This really is an MSDN-type query; I'd think there would be sample code there demonstrating the techniques. Fortunately, I've not had to worry about that level of storage since CP/M, Forth and M68K processors! :) (Although lots of fun, a completely different era and target). --
From: dpb on 21 Jun 2008 13:01 dpb wrote: > Lorin wrote: >> Yes, it is the relationship to the "physical" disk allocation that I >> do not understand. > ... > The IOCTL_DISK_GET_DRIVE_GEOMETRY DeviceIoControl operation returns > information about the physical disk's geometry: type, number of > cylinders, tracks per cylinder, sectors per track, and bytes per sector. .... I was just closing the Win32 API reference and saw a reference in the index list near where it was open which led me to-- > The disk-space list enables you to calculate the disk space required > to complete the installation operations. After you create a disk-space > list and add file operations to it, you can query the list to determine > the target drives specified by the file operations, and the disk space > required on each drive. .... > You can add or remove file operations to the disk-space list and > recalculate the disk space required. This functionality enables you to, > for example, write a program that interacts with the user, allowing him > or her to choose what components they want to install based on the disk > space required. > ... > The disk-space list functions round file sizes to the disk cluster > boundaries. It's part of the Setup API. May be what you're looking for??? (Note my Win SDK documentation is now getting quite long in the tooth so may not be up to date for Vista but there has to be a replacement even if my doc's are obsolete). --
|
Next
|
Last
Pages: 1 2 3 Prev: VB6 project and Crystl32.ocx Next: Read a unique ID from the registry ? |