Collabora Office 24.04 Help
특정 파일 또는 디렉토리의 이름이나 지정한 검색 경로와 일치하는 드라이브 또는 디렉토리에 있는 모든 파일과 디렉토리의 이름을 구합니다.
Dir [(PathName As String [, Attributes As Integer])]
String
PathName: Any string expression that specifies the search path, directory or file. This argument can only be specified the first time that you call the Dir function. If you want, you can enter the path in URL notation.
Attributes:Any integer expression that specifies bitwise file attributes. The Dir function only returns files or directories that match the specified attributes. You can combine several attributes by adding the attribute values:
0 : 일반 파일입니다.
16 : 디렉토리의 이름만 구합니다.
이 속성을 사용하여 파일 또는 디렉토리가 존재하는지 검사하거나 특정 디렉토리에 있는 모든 파일과 폴더를 확인합니다.
파일이 존재하는지 확인하려면 해당 파일의 전체 경로와 이름을 입력합니다. 파일 또는 디렉토리 이름이 존재하지 않을 경우 Dir 함수는 빈 문자열("")을 구합니다.
To generate a list of all existing files in a specific directory, proceed as follows: The first time you call the Dir function, specify the complete search path for the files, for example, "D:\Files\*.ods". If the path is correct and the search finds at least one file, the Dir function returns the name of the first file that matches the search path. To return additional file names that match the path, call Dir again, but with no arguments.
To return directories only, use the attribute parameter. The same applies if you want to determine the name of a volume (for example, a hard drive partition).
Sub ExampleDir
REM Displays all files and directories
Dim sPath As String
Dim sDir As String, sValue As String
sDir="Directories:"
sPath = CurDir
sValue = Dir$(sPath + getPathSeparator + "*",16)
Do
If sValue <> "." And sValue <> ".." Then
If (GetAttr( sPath + getPathSeparator + sValue) And 16) >0 Then
REM get the directories
sDir = sDir & chr(13) & sValue
End If
End If
sValue = Dir$
Loop Until sValue = ""
MsgBox sDir,0,sPath
End Sub