'존재여부'에 해당되는 글 1건

Posted on 2011/09/28 00:46 Url http://www.svkor.com/blog/11
Filed Under 프로그래밍/Visual Basic


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
2011/09/28 00:46 2011/09/28 00:46

About

by 축복

Counter

· Total
: 6446
· Today
: 8
· Yesterday
: 28