相当于 VB6 中的 Directory.CreateDirectory() [英] Equivalent of Directory.CreateDirectory() in VB6

查看:23
本文介绍了相当于 VB6 中的 Directory.CreateDirectory()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试一次创建多层文件夹 C:\pie\applepie\recipies\不使用几个不同的命令,是否有类似于 Directory.CreateDirectory()

Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different commands, is there an easy way similar to Directory.CreateDirectory()

推荐答案

这是我在我的一个项目中使用的一些代码.它需要为文件系统对象添加一个引用到项目中.

Here's some code I used in one of my projects. It requires a reference be added to the project for the file system object.

首先,单击 Project -> References,向下滚动到Microsoft Scripting Runtime"并选择它.然后就可以使用这个函数了:

First, click Project -> References, scroll down to "Microsoft Scripting Runtime" and select it. Then you can use this function:

Public Sub MakePath(ByVal Folder As String)

    Dim arTemp() As String
    Dim i As Long
    Dim FSO As Scripting.FileSystemObject
    Dim cFolder As String

    Set FSO = New Scripting.FileSystemObject

    arTemp = Split(Folder, "\")
    For i = LBound(arTemp) To UBound(arTemp)
        cFolder = cFolder & arTemp(i) & "\"
        If Not FSO.FolderExists(cFolder) Then
            Call FSO.CreateFolder(cFolder)
        End If
    Next

End Sub

这篇关于相当于 VB6 中的 Directory.CreateDirectory()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆