VB6에서 파일 또는 폴더의 존재 여부를 확인하는 방법은 여러가지가 있다.
그 중에서 간단한 두 가지 정도만 예제 함수를 통해 알아보자.
① 파일 존재 여부 확인(폴더 존재 여부는 확인 불가능)
Private Function ExistFile(ByRef Path As String) As Long On Error Goto OnErr If FileLen(Path) Then ExistFile = 1& Else ExistFile = 0& End If Exit Function OnErr: End Function
② 파일 / 폴더 존재 여부 확인
Private Function ExistFile(ByRef FilePath As String) As Long If LenB(Dir$(FilePath)) Then ExistFile = 1& Else ExistFile = 0& End If End Function Private Function ExistFolder(ByRef FolderPath As String) As Long If LenB(Dir$(FolderPath, vbDirectory)) Then ExistFolder = 1& Else ExistFolder = 0& End If End Function
