To expand on what slighthaze has said, you can test for the existence of a folder and then create it if it does not.
lcFolder = [E:\My new folder]
IF !DIRECTORY(lcFolder)
[tab]ON ERROR llError = .T.
[tab]MD (lcFolder)
[tab]ON ERROR DO Errortrap WITH ;
[tab][tab]SYS(16),;
[tab][tab]LINENO(),;
[tab][tab]ERROR(),;
[tab][tab]MESSAGE(1),;
[tab][tab]MESSAGE
ENDI
IF llError
[tab]llError = .F.
[tab]MESSAGEBOX([Unable to create folder])
ENDI
If you have VFP 8.0 you can use the TRY...CATCH...FINALLY command instead to trap any errors.
Remember that MD (MKDIR) can only add one level of directory at a time, you'll need to "loop" Chris's code for the generic case of a "make directory" like "c:\folder1\folder1a\folder1b\folder1c\".
wgcs,
You are right, it really works! Well, it's either a "senior" moment/memory, or there were circumstances that made me write the "looping" code - I'll have to investigate this.
I think it was added in VFP5 or VFP6... I remember it failing sometime in the past, and once in VFP6 I started to write the looping code, but made a mistake and it worked anyway....
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.