Apache OpenOffice (AOO) Bugzilla – Issue 13601
The Dir() command does not return files when directories are also requested
Last modified: 2013-02-24 21:01:14 UTC
According to the documentation, the Dir command should include dirs and files if requested. If you include directories, then files are NOT returned! As taken from the help file: Sub ExampleDir REM Displays all files and directories Dim sFile as String, sPath As String Dim sDir as String, sValue as String Dim iFIle as Integer sFile= "Files: " sDir="Directories:" iFile = 0 sPath = CurDir Rem 0 : Normal files. Rem 2 : Hidden files. Rem 4 : System files. Rem 8 : Returns the name of the volume Rem 16 : Returns the name of the directory only. sValue = Dir$(sPath, 0 + 2 + 4 + 16) REM 16 + 2 + 4 'sValue = Dir$(sPath, 22) REM 16 + 2 + 4 Do If sValue <> "." and sValue <> ".." Then If (GetAttr( sPath + getPathSeparator() + sValue) AND 16) > 0 Then REM here the directories sDir = sDir & chr(13) & sValue Else REM here the files If iFile Mod 3 = 0 Then sFile = sFile + Chr(13) iFile = iFile + 1 sFile = sFile + sValue &"; " End If End If sValue = Dir$ Loop Until sValue = "" MsgBox sDir,0,sPath MsgBox "" & iFile & " " & sFile,0,sPath End sub
Changed to a scripting issue as it should be
Perhaps this is NOT a bug because the online help specifically says: 16 : Returns the name of the directory only. Which could be interpreted to mean that if the directory is requested that nothing else is returned and the fact that the included example does not seem to expect this is of no consequence! Andrew Pitonyak
I am marking this as invalid after further thought. An attribute of zero means return files and if obtaining the directories did not prevent files from being returned there would be no method of finding only directories.
Closed