Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to work with files in system/hidden folders
Message
From
26/11/2000 00:32:26
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00314887
Message ID:
00445463
Views:
41
>>Nadya,
>>
>>Go ahead and FAQ it is you want. There's some discussion of it over on the Wiki too. There's no doubt that a few calls to a builtin function is going to be significantly faster than thousands of calls to a COM object.
>>
>Found two interesting links in WiKi:
>http://fox.wikis.com/wc.dll?Wiki~WindowsScriptingHost~WIN_COM_DNA
>http://fox.wikis.com/wc.dll?Wiki~RecursionInVFP~VFP
>

And then for copying things recursively where you don't care about pulling things back, just copying all the .DBF, .FPT and .CDX files to a backup directory:
DECLARE INTEGER SHFileOperation IN SHELL32.DLL STRING @ LPSHFILEOPSTRUCT
DECLARE INTEGER GetActiveWindow IN WIN32API
SET PROCEDURE TO CLSHEAP ADDITIVE
oHeap = CREATEOBJ('Heap')
#DEFINE FO_COPY 2
#DEFINE FOF_NOCONFIRMATION 0x10    &&  Don't prompt the user.
#DEFINE FOF_NOCONFIRMMKDIR 0x200   &&  don't confirm making any needed dirs
cSourceString = 'C:\MyOldDir\*.DBF' + CHR(0) + ;
                'C:\MyOldDir\*.FPT' + CHR(0) + ;
                'C:\MyOldDir\*.CDX' + CHR(0) + CHR(0)
cDestString = 'D:\MyNewDir' + CHR(0) + CHR(0)
nStringBase = oHeap.AllocBlob(cSourceString+cDestString)
cFileOpStruct = NumToDWORD(GetActiveWindow()) + ;
                NumToDWORD(FO_COPY) + ;
                NumToDWORD(nStringBase) + ;
                NumToDWORD(nStringBase + LEN(cSourceString)) + ;
                NumToDWORD(FOF_NOCONFIRMMKDIR + FOF_NOCONFIRMATION) + ;
                CHR(0) + ;
                NumToDWORD(0) + ;
                NumToDWORD(0)
IF SHFileOperation(cFileOpStruct) = 0
   *  It worked
ELSE
   *  It didn't
ENDIF
oHeap = ''
>I decided not to repeat this discussion.
>
>
>>>I've just ran tests on my local Windows 95 machine c drive:
>>>Results: 19866 files in 4 sec by adir and in 78 sec. by FSO. (time periods are the same in bunch of tests).
>>>Also I looked in MSDN online help on Scripting.FileSystemObject and I didn't find a way to specify file sceleton, like "*.scx" (we can do it in adir())
>>>
>>>I modified a little these programs (I'm going to implement it for searching specific string in specific Form's method Thread #430305)
>>>
>>>BTW, I think both approaches should be placed in FAQ section here, because they are very important. What do you think?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform