Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get file size
Message
 
À
25/07/2001 15:24:52
Patrick O'Neil
American Specialty Information Services
Roanoke, Indiana, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00535088
Message ID:
00535310
Vues:
15
>>>>>Just curious, is there a way to get a file size without using ADIR()?
>>>>>John
>>>>
>>>>Sure. The Size property of the Windows Script Host's Scripting.FileSystemObject.
oFSO = CREATEOBJECT("Scripting.FileSystemObject")
>>>>oFile = oFSO.GetFile(lcfile)
>>>>? oFile.Size
Natively, there's also FSIZE(), but you have to SET COMPATIBLE to ON (by default, it's off).
>>>
>>>george -
>>>
>>>i assume you need to have WSH installed on the machine to to this ?
>>
>>Yes, but it's becoming more and more likely that this is the case (as Win2K and Win Me boxes increase). It's fairly easy to check if it is. Just use the registry class in the FFC to check for the entry of VBScript.RegExp. That'll tell you if one of the more recent versions is installed.
>>
>>I made it a habit to check for the presence of it using a post-setup executable in VFP 6.0 and installing it if it wasn't present.
>
>
>
>
>i've only researched WSH enough to find out what it can do and how to use it.
>it seems there is a lot of overlap in functionality between WSH and the
>Windows API. i've seen in several of your posts, recommendations to use
>WSH host for various things. is that just a personal preference (compared
>to API) or are more things available or just plain easier (in your opinion)
>to do system things using WSH ?

Patrick,

I'm lazy. I'll admit to anyone who cares to ask. Would I use the WSH instead of the API? Sure, if what the WSH gave me could do what the API could. Further, the less code to maintain, the better. Further the WSH does expose some functionality that you can't access even with API calls from VFP (manipulating shortcut links, for example).

However, there are some things that you have to go to the API for. An example would be modifying a file's date/time stamp. In the WSH, they're read-only properties.

All the WSH does is wrap a good deal of functionality that's normally available in the API and exposure as a COM object. Anything that can serve as a COM client can use.

If you're interested in learning some more of what the WSH can do, check out the series of articles Ed Rauh and I wrote for the newsletter at www.vfug.org. They began last September and are available on-line.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform