Dir Function

Liveras la nomon de dosiero, dosierujo, aŭ ĉiuj dosieroj kaj la dosierujoj sur diskingo aŭ en dosierujo kiu kongruas kun la specifita serĉa vojprefikso.

Syntax:


Dir [(PathName As String [, Attributes As Integer])]

Return value:

Ĉeno

Parameters:

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 : Ordinaraj dosieroj.

16 : Liveras nur la nomon de la dosierujo.

Uzu ĉi tiun atributon por kontroli ĉu ekzistas iu dosiero aŭ dosierujo, aŭ por trovi ĉiujn dosierojn kaj dosierujojn en specifa dosierujo.

Por kontroli ĉu dosiero ekzistas, enigu la tutan vojprefikson kaj nomon de la dosiero. Se la dosiero aŭ dosierujo ne ekzistas, la funkcio Dir liveras senlongan ĉenon ("").

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).

Error codes:

5 Nevalida procedurvoko

53 Dosiero ne trovita

Example:


Sub ExampleDir
REM Vidigas ĉiujn dosierojn kaj dosierujojn
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 trovi la dosierujojn
                sDir = sDir & chr(13) & sValue
            End If
        End If
        sValue = Dir$
    Loop Until sValue = ""
    MsgBox sDir,0,sPath
End Sub

Bonvolu subteni nin!