A file is a collection of digital data stored as a single object on a disk. The type of data stored in a file depends on its file type, typically consisting of text, images, multimedia audio and video streams, data libraries, executable software, or other information. A file can be identified by its filename, extension, and location in the disk's file system.
Every file on your computer starts with a header — a special string that tells software programs and the computer's operating system how its contents are encoded, along with metadata like the file's author, created date, and total file size. For example, a JPEG image's header starts with a string that identifies it as a JPEG image, then includes other information like its dimensions, color information, and compression settings. Next comes the file's contents, encoded as either human-readable plain text (using ASCII, UTF-8, or another text encoding method) or as binary data. Finally, a file ends with either an end-of-file marker (another special string like the file header) or by reaching the end of the file size specified in the header.
When a program opens a file, it copies the file from the storage disk to the system memory (RAM), where it can read and modify data much faster. Any changes to a file made while it is open won't be committed to the version on the disk until you save it. You can also move or copy a file to a new folder or another disk entirely; you can also transfer a file to another location over a network connection or the Internet. If you don't need a file anymore, you can delete it to free up its disk space.
There are countless file types that each store data in a file in their own way. The most common way to identify a file's type is by looking at its file extension, which is found at the end of the file name and is typically three or four letters after a period (.). For example, plain text files use the extension .TXT, while a file with the .PNG extension is a PNG image.