For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > February 2005 > Return Large File Size Function...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Return Large File Size Function...
Vincent

2005-02-26, 3:55 am

Hello Friends,

Sorry for such a newbie type question but I need to get the proper file size
returned to me for large files. I found a function but I am not quite sure
how to use it. I'm not sure what to send the FileSizeHigh and the
FileSizeLow in the function.

Here it is:
http://www.freevbcode.com/ShowCode.asp?ID=6836

Any help help/example would be much appreciated. :)

Thanks,
Vincent


J French

2005-02-26, 8:55 am

On Fri, 25 Feb 2005 23:05:56 -0800, "Vincent" <vincent938@hotmail.com>
wrote:

>Hello Friends,
>
>Sorry for such a newbie type question but I need to get the proper file size
>returned to me for large files. I found a function but I am not quite sure
>how to use it. I'm not sure what to send the FileSizeHigh and the
>FileSizeLow in the function.
>
>Here it is:
>http://www.freevbcode.com/ShowCode.asp?ID=6836
>
>Any help help/example would be much appreciated. :)


Yes, well that little article is a good example of cracking a walnut
with a chainsaw

The simplest thing is to replace the two 4 byte Longs
nFileSizeHigh;
nFileSizeLow;
With one 8 byte currency variable

Multiply what comes back in the currency variable by 10,000 and you
have the file size.

An alternative method is to use CopyMemory to move the bytes into a
currency - or LSet with two UDTs

Personally I would not bother with the complicated solutions.


Kelly Ethridge

2005-02-26, 8:55 pm

Hello,

Replacing the nFileSizeHigh and nFileSizeLow with a single nFileSize as Currency will fail because
the DWord values are in the wrong order. The Low will become the upper 32bits and High will
become the lower 32bits in the Currency datatype. The DWords need to be reversed is some fashion.

Kelly

"J French" <erewhon@nowhere.uk> wrote in message news:4220407d.159650567@news.btclick.com...
> On Fri, 25 Feb 2005 23:05:56 -0800, "Vincent" <vincent938@hotmail.com>
> wrote:
>
>
> Yes, well that little article is a good example of cracking a walnut
> with a chainsaw
>
> The simplest thing is to replace the two 4 byte Longs
> nFileSizeHigh;
> nFileSizeLow;
> With one 8 byte currency variable
>
> Multiply what comes back in the currency variable by 10,000 and you
> have the file size.
>
> An alternative method is to use CopyMemory to move the bytes into a
> currency - or LSet with two UDTs
>
> Personally I would not bother with the complicated solutions.
>
>



J French

2005-02-27, 8:55 am

On Sat, 26 Feb 2005 12:28:47 -0800, "Kelly Ethridge"
<kelly@kellyethridge.com> wrote:

>Hello,
>
>Replacing the nFileSizeHigh and nFileSizeLow with a single nFileSize as Currency will fail because
>the DWord values are in the wrong order. The Low will become the upper 32bits and High will
>become the lower 32bits in the Currency datatype. The DWords need to be reversed is some fashion.


Well caught - my brain farted
J French

2005-02-27, 8:55 am

On Sun, 27 Feb 2005 09:52:50 +0000 (UTC), erewhon@nowhere.uk (J
French) wrote:

This will swap the order in a currency

Option Explicit

Private Declare Sub CopyMemory _
Lib "kernel32" _
Alias "RtlMoveMemory" _
(pDst As Any, _
pSrc As Any, _
ByVal ByteLen As Long)


Private Sub Command1_Click()
Dim C As Currency

C = 99999999999#
Call SwapLongs(C)
Me.Print C

Call SwapLongs(C)
Me.Print C

End Sub

Private Sub SwapLongs(C As Currency)
Dim H As Long

' hold first 4 bytes
Call CopyMemory(H, C, 4)
' shunt second long left
Call CopyMemory(C, ByVal VarPtr(C) + 4, 4)
' fill in rightmost long
Call CopyMemory(ByVal VarPtr(C) + 4, H, 4)

End Sub

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com