|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Are there alternatives to using WIN32_Find_Data?a file's size. Well, the described method does not work for large files, e.g., for a file of 25406543872 bytes. I ran into the problem in my own code, but I've seen the same problem with other well known code posted on the web. I've communicated this privately to an author of similar code posted at his web site. The following just does not get the job done, even if converted to the Currency data type. (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow Is there a more reliable way to get the file size? I sure wish MSFT would not publish incorrect info, oh well, I can dream, n'est-ce pas!? Let's start a revolution and fix this problem. No revolution needed. VB6 is geared toward 32 bit operations and
as such it will fail at certain points. I overcame the problem a long time ago with the help of this newsgroup. Look at the post several days ago entitled "Zip API in WindowsXP" about 2/3 of the way down. And also my post at PSC: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=49884&lngWId=1 AGP Show quoteHide quote "Howard Kaikow" <kai***@standards.com> wrote in message news:Ozbaul3SGHA.5908@TK2MSFTNGP14.phx.gbl... > The description of the Win32_Find_Data structure documents how to determine > a file's size. > > Well, the described method does not work for large files, e.g., for a file > of 25406543872 bytes. > > I ran into the problem in my own code, but I've seen the same problem with > other well known code posted on the web. > I've communicated this privately to an author of similar code posted at his > web site. > > The following just does not get the job done, even if converted to the > Currency data type. > > (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow > > Is there a more reliable way to get the file size? > > I sure wish MSFT would not publish incorrect info, oh well, I can dream, > n'est-ce pas!? > > Let's start a revolution and fix this problem. > > Thanx, I'll take a look.
"AGP" <sindizzy.***@softhome.net> wrote in message http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=49884&lngWId=1news:uXgTf.48502$F_3.21829@newssvr29.news.prodigy.net... > No revolution needed. VB6 is geared toward 32 bit operations and > as such it will fail at certain points. I overcame the problem a long > time ago with the help of this newsgroup. Look at the post several > days ago entitled "Zip API in WindowsXP" about 2/3 of the way down. And also > my > post at PSC: > Show quoteHide quote > > AGP > > > > > "Howard Kaikow" <kai***@standards.com> wrote in message > news:Ozbaul3SGHA.5908@TK2MSFTNGP14.phx.gbl... > > The description of the Win32_Find_Data structure documents how to > determine > > a file's size. > > > > Well, the described method does not work for large files, e.g., for a file > > of 25406543872 bytes. > > > > I ran into the problem in my own code, but I've seen the same problem with > > other well known code posted on the web. > > I've communicated this privately to an author of similar code posted at > his > > web site. > > > > The following just does not get the job done, even if converted to the > > Currency data type. > > > > (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow > > > > Is there a more reliable way to get the file size? > > > > I sure wish MSFT would not publish incorrect info, oh well, I can dream, > > n'est-ce pas!? > > > > Let's start a revolution and fix this problem. > > > > > >
Show quote
Hide quote
> The description of the Win32_Find_Data structure documents how to Have a look at this post from a few days ago on the subject:> determine > a file's size. > > Well, the described method does not work for large files, e.g., for a file > of 25406543872 bytes. > > I ran into the problem in my own code, but I've seen the same problem with > other well known code posted on the web. > I've communicated this privately to an author of similar code posted at > his > web site. > > The following just does not get the job done, even if converted to the > Currency data type. > > (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow > > Is there a more reliable way to get the file size? > > I sure wish MSFT would not publish incorrect info, oh well, I can dream, > n'est-ce pas!? http://groups.google.co.uk/group/microsoft.public.vb.winapi/msg/3221dfa4e713ed7e If you need a version that also copes with Unicode file names then I can post that one instead. Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ Thanx, I'll take a look.
Show quoteHide quote "Mike D Sutton" <ED***@mvps.org> wrote in message http://groups.google.co.uk/group/microsoft.public.vb.winapi/msg/3221dfa4e713ed7enews:eKToTG4SGHA.1868@TK2MSFTNGP10.phx.gbl... > > The description of the Win32_Find_Data structure documents how to > > determine > > a file's size. > > > > Well, the described method does not work for large files, e.g., for a file > > of 25406543872 bytes. > > > > I ran into the problem in my own code, but I've seen the same problem with > > other well known code posted on the web. > > I've communicated this privately to an author of similar code posted at > > his > > web site. > > > > The following just does not get the job done, even if converted to the > > Currency data type. > > > > (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow > > > > Is there a more reliable way to get the file size? > > > > I sure wish MSFT would not publish incorrect info, oh well, I can dream, > > n'est-ce pas!? > > Have a look at this post from a few days ago on the subject: > Show quoteHide quote > If you need a version that also copes with Unicode file names then I can > post that one instead. > Hope this helps, > > Mike > > > - Microsoft Visual Basic MVP - > E-Mail: ED***@mvps.org > WWW: Http://EDais.mvps.org/ > > The mechanism diddling with the value 2^32 seems to get around the problem.
No need to use, ugh!, Variant, works with Currency type. Here's what I used:
curHigh = CCur(WFD.nFileSizeHigh) curLow = CCur(WFD.nFileSizeLow) If curHigh < 0 Then curHigh = curHigh + curBit32 End If If curLow < 0 Then curLow = curLow + curBit32 End If ByteCount = (curHigh * curBit32) + curLow Where curHigh, curLow, ByteCount, and curBit32 are type Currency.
Show quote
Hide quote
"Howard Kaikow" <kai***@standards.com> wrote in message That's pretty much the same solution as posted here:news:eMXnGC5SGHA.5108@TK2MSFTNGP09.phx.gbl... > Here's what I used: > > curHigh = CCur(WFD.nFileSizeHigh) > curLow = CCur(WFD.nFileSizeLow) > If curHigh < 0 Then > curHigh = curHigh + curBit32 > End If > If curLow < 0 Then > curLow = curLow + curBit32 > End If > ByteCount = (curHigh * curBit32) + curLow > > Where curHigh, curLow, ByteCount, and curBit32 are type Currency. > > http://www.freevbcode.com/ShowCode.asp?ID=6836 Looks like you fixed it. Jim Edgar
Show quote
Hide quote
"Jim Edgar" <djedgarRemoveT***@cox.net> wrote in message Ayup.news:uDN4PY5SGHA.4608@tk2msftngp13.phx.gbl... > > "Howard Kaikow" <kai***@standards.com> wrote in message > news:eMXnGC5SGHA.5108@TK2MSFTNGP09.phx.gbl... > > Here's what I used: > > > > curHigh = CCur(WFD.nFileSizeHigh) > > curLow = CCur(WFD.nFileSizeLow) > > If curHigh < 0 Then > > curHigh = curHigh + curBit32 > > End If > > If curLow < 0 Then > > curLow = curLow + curBit32 > > End If > > ByteCount = (curHigh * curBit32) + curLow > > > > Where curHigh, curLow, ByteCount, and curBit32 are type Currency. > > > > > > That's pretty much the same solution as posted here: > > http://www.freevbcode.com/ShowCode.asp?ID=6836 > > Looks like you fixed it. I've lost track of how many hours/daze/weeks/etc. I've wasted because MSFT posts incorrect solutions. Of course, what the gorilla says must be correct, so we SHEEPishly just copy their crap. Show quoteHide quote > > Jim Edgar > > On Sun, 19 Mar 2006 15:05:51 -0500, "Howard Kaikow"
<kai***@standards.com> wrote: >Here's what I used: I prefer to use two UDTs> > curHigh = CCur(WFD.nFileSizeHigh) > curLow = CCur(WFD.nFileSizeLow) > If curHigh < 0 Then > curHigh = curHigh + curBit32 > End If > If curLow < 0 Then > curLow = curLow + curBit32 > End If > ByteCount = (curHigh * curBit32) + curLow > >Where curHigh, curLow, ByteCount, and curBit32 are type Currency. - on contains a Currency, the other has two Longs LSet the 'Longs' UDT into the Currency UDT and you have a calculation-less conversion Then multiply the Currency by 10,000 and off you go. Has it been the conclusion that the following works for all the OS?
curHigh = CCur(WFD.nFileSizeHigh) curLow = CCur(WFD.nFileSizeLow) If curHigh < 0 Then curHigh = curHigh + curBit32 End If If curLow < 0 Then curLow = curLow + curBit32 End If ByteCount = (curHigh * curBit32) + curLow Where curHigh, curLow, ByteCount, and curBit32 are type Currency. |
|||||||||||||||||||||||