Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Delete / Copy files
Message
De
29/03/2002 00:46:14
 
 
À
28/03/2002 15:59:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00638661
Message ID:
00638833
Vues:
22
>I am adding new functionality to our software (which is currently running in VFP 5.0) to automatically copy our data files to select user's pcs in case our users ever lose their network connection. I thought what I was doing was going to be very easy but is turning out to be very difficult. First I need to delete the existing files, then download the current files. I am trying to do the following but it is not working...it appears as though I cannot use a variable name in DELETE / COPY commands.
>
>SCAN
>cTableName = SUBSTR(TEMPDBFFIX.TABLE, AT('\', TEMPDBFFIX.TABLE,1)+1)
>cFileName = lcTemplatePath + 'TEMPLATE\DATA\' + TRIM(cTableName) + '.*'
>*-- Delete all tables in Template Data directory
>DELETE FILE cFileName
>*-- Copy files from production fileshare to backup template on server
>cTableName = OAPP.CDEFAULT + TRIM(TEMPDBFFIX.TABLE) + '.*'
>COPY FILE cTableName TO cFileName
>ENDSCAN
>
>I am scanning a table that has a list of all tables in the database to make it easier, at least I thought. Does anyone have an suggestions as to how I can make this work, or if there is an easier way to do it?
>

The obvious approach would be to use ADIR() to populate a list of files, and then use either the native VFP COPY FILE, or the Win32 API CopyFile(), to do the work. You can also work with the WSH Scripting.FileSystemObject, which has mechanisms to copy and delete entire folders or specific filesfrom its COM methods, as documented from a VFP POV in a 5 part article by George Tasker and me starting with the August or September issue, all of which can be downloaded from www.vfug.org. Wrox Press has an excellent book on the WSH by Dino Esposito that I highly recommend, as well as their VBScript Programmers' Reference. The Shell.Application ob also offers a method forcopying files to a specified directory.

There is a very powerful API call which can do bulk deletions, copies and renames - SHFileOperation(). You can find details on it in the Win32 API section of UT. It is notnearly as simple to implement the first time working with it - while remarkably powerful and flexible, it's relatively complex and demanding to configure the first few times implementing it. It's worth a peek.
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform