If you want to protect a directory or its contents, you need to look to the forum titled
.htaccess
It is a simple type of file read by your own web server.
robots.txt can be considered more of an honor-system based suggestion to bots of what to do or not do.
.htaccess is literally access control!
generally, it is best to have a blank robots.txt file if you don't want to have server logs that talk about robots.txt all the time.
if you do want those logs and want to be searched and indexed (usually yes), have no robots.txt file.
if you want to just protect particular areas of your site, use .htaccess
it is a set it and forget thing.