How to disable directory files from accessing?

If you are doing it for security purpose you can use following steps:
add index.php file to each folder that you don’t want to show the content of.

<?php // Just leave the index.php file blank

And second way to reduce insecurity is to use

if(!defined('ABSPATH')){ exit; }

inside every php files to no access that file directly.
I hope it helps.
And you are welcome to explore further on your own.
Good Luck!!!