Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining file size
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01019302
Message ID:
01039175
Vues:
28
Hi Craig,

It seems that your code can return incorrect file size in some cases. Take a look at Re: Can't make getFileSize work on really big files (20GB) Message #1039133

>In addition to what Mike has already provided you, here is a function for returning the size on disk of a file (this code is modified/enhanced version of something I got from somewhere awhile back, I failed to note the source so I am unable to give due credit)
>
?GetSizeOnDisk(GETFILE(), 1)
>
>************************************
>FUNCTION GetSizeOnDisk(tcFileName, tnType)
>************************************
>*	tnType = 0 for Bytes
>*	tnType = 1 for KB
>*	tnType = 2 for MB
>*	tnType = 3 for GB
>************************************
>	#DEFINE OF_READ 0
>	#DEFINE OF_SHARE_DENY_NONE 64
>	#DEFINE HFILE_ERROR -1
>	#DEFINE DWORDPLUS 4294967296
>	DECLARE INTEGER GetFileSize IN kernel32;
>	    INTEGER   hFile,;
>	    INTEGER @ lpFileSizeHigh
>
>	DECLARE INTEGER OpenFile IN kernel32;
>	    STRING   lpFileName,;
>	    STRING @ lpReOpenBuff,;
>	    INTEGER  wStyle
>
>	DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
>
>	LOCAL lpReOpenBuff, hFile, lnSizeLo, lnSizeHi, lnReturn
>
>	IF PCOUNT() < 2
>		tnType = 1
>	ENDIF
>
>	IF TYPE("tcFileName") != "C" OR !FILE(tcFileName)
>		lnReturn = 0
>	ELSE
>		lpReOpenBuff = REPLI (Chr(0), 250)
>		hFile = OpenFile (tcFileName, @lpReOpenBuff, OF_SHARE_DENY_NONE)
>		
>		IF hFile <> HFILE_ERROR
>		    lnSizeHi = 0
>		    lnSizeLo = GetFileSize (hFile, @lnSizeHi)
>		    = CloseHandle (hFile)
>		    lnReturn = lnSizeHi * DWORDPLUS + lnSizeLo / 1024^tnType
>		ELSE
>		    lnReturn = 0
>		ENDIF
>	ENDIF
>	RETURN lnReturn
>ENDFUNC
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform