출처 : http://cafe.naver.com/muchknow.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=82

Public Function IsBeing(경로 As String, Optional 형식 As Byte = 0) As Boolean
'먼저 프로젝트메뉴->참조의 Microsoft Scriping Runtime 을 참조해야 합니다.
'형식 Value : 0 -> 파일, 1 -> 디렉터리,  2 -> 드라이브
    Dim fso As New FileSystemObject
    Dim objDrive As Object


    Select Case 형식
        Case 0
            IsBeing = IIf(fso.FileExists(경로), True, False)
        Case 1
            IsBeing = IIf(fso.FolderExists(경로), True, False)
        Case 2
            IsBeing = IIf(fso.DriveExists(경로), True, False)
    End Select
End Function


 

자동업데이트 스크립트 생성기 만들면서 폴더선택하는 거 한답시고 API폴더 파인드 만질래다가 포기하고

그냥 텍스트 박스에서 써넣은 후 아래 함수로 체크해서 하위폴더중 없는 폴더가 있으면 자동으로 생성하는

함수를 만들었네요.. 인덱스를 Integer을 썼으니 6만 얼마 생성가능한데 OS가 그만큼 지원해주는지는 모르

겠네여.. 어쨋든 유용하게 써먹으시길


'이 함수는 경로를 인수로 받아서 디렉터리가 있는지 확인하고 없으면 생성시켜주는 함수입니다.
Public Function IsBeingDir(StrPath As String) As Boolean
    On Error GoTo err
  
    If IsBeing(StrPath, 1) = True Then
        IsBeingDir = True
        Exit Function
    End If


    Dim FolderCount() As String
    Dim DiffStr As String
    Dim Idx As Integer
    FolderCount = Split(StrPath, "\")

    DiffStr = FolderCount(0)
    For Idx = 1 To UBound(FolderCount)
        DiffStr = DiffStr & "\" & FolderCount(Idx)
        If IsBeing(DiffStr, 1) = False Then
            MkDir DiffStr
        End If
    Next
    IsBeingDir = True
    Exit Function
err:
    IsBeingDir = False
End Function


Posted by 나비:D
:
BLOG main image
by 나비:D

공지사항

카테고리

분류 전체보기 (278)
Programming? (0)
---------------------------.. (0)
나비의삽질 (5)
Application (177)
SQL (51)
Web (27)
etc. (14)
Omnia (0)
---------------------------.. (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

달력

«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Total :
Today : Yesterday :