RemoveFromDirList()
ts
RemoveFromDirList(what: string): void;Removes the specified item(s) from a directory listing that is about to be returned to the client. This function is typically used to hide files or folders from users based on custom logic.
CAUTION
This function is only meaningful when used inside the BeforeSendDirListToClient event-handler. Using it elsewhere will have absolutely no effect.
The what parameter can be:
- The exact name of a file or folder (e.g.,
resume.pdf) - A wildcard pattern (e.g.,
*.pngto match all PNG files)
NOTE
This function does not delete or move files on disk. It only affects what is shown to the client in the directory listing.
Example
ts
{
if (Session) {
// Remove a specific file from the directory list
Session.RemoveFromDirList('resume.pdf');
// Remove all .png files from the directory list
Session.RemoveFromDirList('*.png');
// Remove a folder named 'private'
Session.RemoveFromDirList('private');
} else {
Log('Session object is not available.');
}
}TIP
You can call RemoveFromDirList() multiple times to hide several files or patterns in the same event-handler.
