VB FSO 如何在网上邻居创建文件夹?

解决方案 »

  1.   

    跟创建本地文件夹一样,前提得有创建的权限。
    Dim fso As New FileSystemObject
    fso.CreateFolder "\\192.168.1.5\abc"
      

  2.   


    ' --------------------------------
    ' 自动创建指定的多级文件夹
    ' strPath为绝对路径
    Public Function AutoCreateFolder(strPath) ' As Boolean
            On Error Resume Next
            Dim astrPath, ulngPath, i, strTmpPath
            Dim objFSO
            If InStr(strPath, "\") <= 0 Or InStr(strPath, ":") <= 0 Then
                    AutoCreateFolder = False
                    Exit Function
            End If
            Set objFSO = CreateObject("scripting.filesystemobject")
            If objFSO.FolderExists(strPath) Then
                    AutoCreateFolder = True
                    Exit Function
            End If
            astrPath = Split(strPath, "\")
            ulngPath = UBound(astrPath)
            strTmpPath = ""
            For i = 0 To ulngPath
                    strTmpPath = strTmpPath & astrPath(i) & "\"
                    If Not objFSO.FolderExists(strTmpPath) Then
                            ' 创建
                            objFSO.CreateFolder (strTmpPath)
                    End If
            Next
            Set objFSO = Nothing
            If Err = 0 Then
                    AutoCreateFolder = True
            Else
                    AutoCreateFolder = False
            End If
    End Function
    上面是一个自动创建军多级文件夹的函数。但是这里里有个问题就是网上临居是以“\\”开头的。这里面怎么改一下"\"就能够解决问题了。