Hello Richard,
thanks a lot for the very fast and great help; works great!!!
Before I have seen the RedirectOutput command I tried it with the open and writeline commands; but I got just an output file with no entries. Below you can see the code with FileHandle, Open, Writeline and the Close. Not sure what I'm doing wrong.
Thanks,
Bjoern

Code:

Break ON

$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")
$=SetOption("ASCII","ON")

Dim $sBaseDir
Dim $sDirEnt
Dim $Handle

$Handle = FreeFileHandle()

$sBaseDir="C:\WINNT\"

Open($Handle, "KATEGORIEN.TXT", 1)

$sDirEnt=Dir($sBaseDir)

While $sDirEnt <> "" And @ERROR = 0

If ($sDirEnt <> ".") And ($sDirEnt <> "..") And (GetFileAttr($sBaseDir+"\"+$sDirEnt) & 16)
WriteLine($Handle, $sDirEnt+@CRLF)
EndIf

$sDirEnt = Dir()

Loop

Close($Handle)