Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you change a folder name programatically?
Message
De
10/02/1999 21:36:32
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00186345
Message ID:
00186350
Vues:
20
>Does anyone know how to change a folder name from within a VFP program? I've been told that it can only be done through the Windows API. (Please provide an example. I'm not that familiar with the syntax when using the API.)

I'd recommend using the Scripting.FileSystemObject's MoveFolder method. This requires installation of the Windows Scripting Host's automation objects (you can download the WSH from Microsoft)

oFSO = CREATEOBJ('Scripting.FileSystemObject')
oFSO.MoveFolder("C:\Mydir\OldName","C:\MyDir\A New Name")

You can also do this with the Win32API call MoveFileEx:
DECLARE INTEGER MoveFileEx IN WIN32API ;
   STRING @lpExistingFileName, ;
   STRING @lpNewFileName, ;
   INTEGER dwFlags
IF MoveFileEx("C:\OldDirName","C:\NewDirName",0) # 0
   * it worked
ELSE
   *  it failed, and you need to use GetLastError to find out why
ENDIF
Both the above are off the top of my head, so there may be typos. See the MSDN docs for exact syntax, flag values, restrictions, etc.
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