Skip to content

Modern Fs DirEntry YieldDirectories

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Filesystem › Filesystem Library › WalkOptions.YieldDirectories

WalkOptions.YieldDirectories

Chooses whether a walk returns folders as well as files; true by default.

Syntax

WalkOptions.YieldDirectories

Examples

#import "std/fs"
using fs

dim td as FsResultUStr = CreateTempDir( "fbdoc" )
dim as ustring dir_ = td.Value( )
WriteAllText( PathJoin( dir_, "a.txt" ), "aaa" )
WriteAllText( PathJoin( dir_, "b.txt" ), "bb" )
CreateDir( PathJoin( dir_, "sub" ) )
WriteAllText( PathJoin( dir_, "sub", "c.txt" ), "c" )

'' A WalkOptions field, DEFAULT TRUE: directories are yielded as well
'' as files, before their contents
dim opts as WalkOptions
print opts.YieldDirectories  '' true

opts.YieldDirectories = false
dim as int32 n = 0
for each r in WalkDir( dir_, opts )
    n += 1
next
print n                      '' 3 -- the files only; sub is still descended

RemoveDirAll( dir_ )

Library: Filesystem Library
Category: Filesystem
Documented under: Directories

Clone this wiki locally