RemoveFromDirList()
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)
Only two characters are wildcards: * matches any sequence of characters and ? matches exactly one character. Every other character matches itself, square brackets included, so report[1].pdf hides the file with that exact name and [Docs] hides the folder with that exact name. The same rule applies to file masks sent by FTP clients and to wildcard permission overrides.
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
{
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.
