How does computer memory store the file name?
You are right, the computer saves the file name somewhere. But not, it isn't kept in a &quot;stack&quot; or in &quot;memory&quot;, files are kept on external memory (disk, flashdrive, perhaps even somewhere else &quot;on the cloud&quot;). This memory in turn is organized to give an efficient map from file names (stored in filesystem proper data structures) to file contents (arranged so it is e.g. possible to extend the file, erase it's contents and reclaim the space, ...). When you ask your operating system for the file size, it answers with the user-visible space (as that is what you presumably are interested in). The space used up in management of the above (file name, references to the pieces used by this file, map of free space on the device, directory structure for managing names, ...) is usually not your concern. You can ask for it if you look at &quot;how full is the device&quot;, just that the space used for management usually can't really be associated with a particular file, it is used by many files together.
Get some book on operating systems, and look up &quot;file systems&quot;. Or check simple examples like the (MS-DOS) FAT filesystem or the Unix file system design (just concentrate on the Version 7 one, with it's simple layout). File systems in current use are very complex beasts, trying to squeeze out performance of humongous, glacially slow, rotating disks or levelling wear on fast SSDs.