Skip to content

Modern Fs DirEntry IsValid

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

Home › Filesystem › Filesystem Library › DirIterator.IsValid

DirIterator.IsValid

Returns true while the iterator is on an entry.

Syntax

DirIterator.IsValid( )

Notes

  • still on an element?

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

'' The iterator protocol underneath `for each`: IsValid / Value /
'' MoveNext, the same shape the containers use
dim it as DirIterator = ReadDir( dir_ ).GetIterator( )

print it.IsValid( )          '' true -- there is an entry to read

while it.IsValid( )
    it.MoveNext( )
wend
print it.IsValid( )          '' false -- the directory is exhausted

RemoveDirAll( dir_ )

Library: Filesystem Library
Category: Filesystem
Documented under: Directories

Clone this wiki locally