Quantcast
Channel: Sandstorm's Blog (Home of ssUltimate Library)
Viewing all articles
Browse latest Browse all 160

MKDirs - Create Folder and Missing Sub-Folders in one go!

$
0
0
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:


*******
* 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!


Viewing all articles
Browse latest Browse all 160

Trending Articles