您的位置:程序门 -> vb -> 基础类



vb中有没有自动建立多层目录的方法?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vb中有没有自动建立多层目录的方法?[已结贴,结贴人:morbidangel]
发表于:2007-07-26 15:06:55 楼主
像这样   makedir( "c:\fdsa\fdsa\fdas\fdas ")   这些目录都不存在的话   它一次就可以都建立出来?
发表于:2007-07-26 15:46:551楼 得分:10
没有,自己写一段代码。


public   function   makedir(path   as   string)   as   boolean
        on   error   resume   next
        dim   o_strret   as   string
        dim   o_intitems   as   integer
        dim   o_vntitem   as   variant
        dim   o_stritems()   as   string
        o_stritems()   =   split(path,   "\ ")
        o_intitems   =   0


        for   each   o_vntitem   in   o_stritems()
                o_intitems   =   o_intitems   +   1


                if   o_intitems   =   1   then
                        o_strret   =   o_vntitem
                else
                        o_strret   =   o_strret   &   "\ "   &   o_vntitem
                        mkdir   o_strret
                end   if
        next
        makedir   =   (err.number   =   0)
end   function
发表于:2007-07-26 15:58:252楼 得分:10
private   sub   command1_click()
        mkdirfun   "f:\123\456\789\xyz\opq "
end   sub

private   sub   mkdirfun(byval   spath)
        dim   s   as   string,   x()   as   string
        dim   i   as   long
        x   =   split(spath,   "\ ")
        s   =   x(0)
        for   i   =   1   to   ubound(x)
                s   =   s   &   "\ "   &   x(i)
                if   dir(s,   vbdirectory)   =   " "   then
                        mkdir   s
                end   if
        next
end   sub


快速检索

最新资讯
热门点击