Your question is ambiguous. If somebody was accessing the directory using FTP, then having an index file wouldn't stop the directory listing. I have a feeling that you're talking about HTTP, which can list a directory when there is no index.html file, similar to an FTP listing. Also, there is a difference between a 404 and a 403. A 404 means that the user requested a directory or file that isn't there. A 403 means that the user requested something that is there, but access is denied. You can also provide a 301 redirect message that redirects to another page on your website.
[HTTP] The simplest, and recommended, solution would be to display a 403 error. To do this, just create a file in the directory called ".htaccess" (without the quotes). In this file, just put the line "Options -Indexes" (again, no quotes) and save it. The web server will see this file and know that it shouldn't serve the directory listing and will return HTTP 403 instead.
[HTTP] If you
really want to display a 404 instead of a 403, you can try to create a .htaccess file in the folder above the directory you don't want to list, but put "Redirect 404 /folder" in it, instead. I've read that this works, but don't have a way to test it right now.
[HTTP] If you have mod_rewrite enabled for your server, another way to accomplish the 404 error would be to create an .htaccess file that contains the lines:
RewriteEngine On
RewriteRule ^.*/[\w\d]+$ - [R=404,L]
This will match a slash followed by one or more word/digit characters (aka a directory) [you may need to fiddle with the RegEx to get it to match correctly]. And it will then direct to a 404 error.
Keep in mind, with any of the above solutions, it only prevents a directory listing. If the user knows (or
guesses) the name a specific file, it will still be accessible. It is possible to use .htaccess files to password-protect a directory.
[FTP] If you really were talking about FTP, 404 is not a valid error or status code. The easiest solution with FTP is to disable access for the "anonymous" user (granted, this will deny all access, not just directory listing).