Well I posted this inside foxite last time as a fellow member is wondering how it can be done. Suppose you want to create a folder and several sub-folders like this?
c:\mine\sub1\sub2\my sub3\sub4\sub sub\too deep or not\how.about now\maybe this time
Then this simple function I named MKDirs can make this folder checking and creations for you very easy:
To use this is something like this:
c:\mine\sub1\sub2\my sub3\sub4\sub sub\too deep or not\how.about now\maybe this time
Then this simple function I named MKDirs can make this folder checking and creations for you very easy:
*******
* Author: Jun Tangunan
* Date: December 19, 2013
*
Function MKDirs(lcFolder)
*******
Local lnSub, lnLoop, lcDir
lnSub = Getwordcount(m.lcFolder,'\')
lcDir = ''
For lnLoop = 1 To m.lnSub
lcDir = m.lcDir + Addbs(Getwordnum(m.lcFolder,m.lnLoop,'\'))
Try
Mkdir (m.lcDir)
Catch
Endtry
Next
Return
To use this is something like this:
Local lcFolder
lcFolder = 'c:\mine\sub1\sub2\my sub3\sub4\sub sub\too deep or not\how.about now\maybe this time'
If !Directory(m.lcFolder,1)
MKDirs(m.lcFolder)
Endif
Difference of the native MKDIR() with this? MKDIR() will sometimes fail on folder with spaces or dots. MKDirs() do not.
Cheers!