A file is a container your computer uses to store a single piece of information

A file is a collection of data — text, images, video, code, or anything else — saved under a single name on your computer or phone. When you write a document in Word, take a photo, download a song, or save an email, you are creating a file. Your computer treats that file as a unit: it has a name, a location, a size, and a type that tells your device what program should open it.

Files are the basic building block of how computers store and organize information. Without files, there would be no way to save your work, keep photos, or run programs. Every application on your device — your web browser, email client, photo editor — works by reading, creating, or changing files.

Key Takeaways

  • A file is a named container of data stored on your device, and its type (determined by its extension like .docx or .jpg) tells your computer which program should open it.
  • Files live inside folders, which are containers that hold multiple files and other folders, creating a hierarchical structure that keeps your data organized.
  • File size is measured in bytes, kilobytes, megabytes, and gigabytes — larger files like videos take up more storage space than smaller ones like text documents.
  • Every file has metadata attached to it, including when it was created, when it was last changed, and who owns it, which helps you find and manage files later.

How file names and extensions work

Every file has two parts to its name: the actual name you give it, and the file extension — a short code after a period that identifies what type of file it is. When you save a document as "Budget 2024.docx", the "Budget 2024" is the name you chose, and ".docx" is the extension that tells your computer it is a Microsoft Word document.

The extension matters because it tells your device which program to use when you double-click the file. A file named "photo.jpg" will open in your photo viewer or image editor, while "photo.txt" would try to open in Notepad, even though it is the same picture. Common extensions include .pdf for documents, .mp3 for music, .mp4 for video, .xlsx for spreadsheets, and .png for images. Your computer has a list of which program handles each extension, and you can change those associations if you want a different program to open a particular file type.

Files, folders, and the hierarchy that organizes them

Files do not sit loose on your computer — they live inside folders (also called directories). A folder is a container that holds files and other folders inside it, creating a tree-like structure. Your computer usually starts with a main folder called "Documents" or "Users", and inside that are subfolders like "Photos", "Work", or "Projects". Inside those folders are more folders, and eventually files.

This hierarchy lets you organize thousands of files so you can find them later. Instead of having every file dumped in one place, you can create a folder structure that makes sense to you: a "2024 Taxes" folder inside a "Financial" folder, or a "Client Names" folder inside a "Work" folder. When you save a file, you choose which folder it goes into. The full path to a file — the complete list of folders you have to open to reach it — might look like "Documents > Work > Client Names > Johnson Contract.docx".

File size and what it means for your storage

Every file takes up space on your device, measured in bytes. A byte is the smallest unit of digital storage. For practical purposes, file sizes are usually shown in larger units: a kilobyte (KB) is about 1,000 bytes, a megabyte (MB) is about 1,000 kilobytes, and a gigabyte (GB) is about 1,000 megabytes. A text document might be 50 KB, a photo might be 3 MB, and a movie might be 700 MB or larger.

File size matters because your device has limited storage. If your phone has 64 GB of storage and you fill it with large video files, you will run out of space and not be able to save new files. Smaller files like text documents barely make a dent, but video, music, and high-resolution photos add up quickly. You can check how much storage you have left by opening your device's settings, and you can free up space by deleting files you no longer need or moving them to an external drive or cloud storage.

Metadata: the hidden information attached to every file

Beyond the name and content, every file carries metadata — information about the file itself. This includes the date and time the file was created, the date it was last modified, the file size, the owner, and sometimes tags or notes you add yourself. Your operating system tracks this automatically, and it is one reason you can sort files by date or search for files you changed last week.

Metadata is useful for finding files later. If you remember you edited a photo sometime in March but cannot remember its name, you can search by date modified. If you want to find all the Word documents you created in a particular folder, you can sort by file type. Some programs let you add your own metadata — like marking a photo with a star or adding a description — which makes searching and organizing even easier. When you move or copy a file, the metadata usually comes with it, though the "date modified" may update to reflect the new action.

Different file types and what they do

Files come in many types, each designed for a different purpose. Document files like .docx, .pdf, and .txt hold text and formatting. Image files like .jpg, .png, and .gif store pictures. Audio files like .mp3 and .wav hold music or voice recordings. Video files like .mp4 and .mov contain movies or clips. Spreadsheet files like .xlsx organize data in rows and columns. Compressed files like .zip bundle multiple files together and reduce their size for easier sharing.

Each file type is optimized for its content. A .jpg image file compresses photos to save space, while a .png file preserves more detail but takes up more room. A .pdf file locks formatting so a document looks the same on any device, while a .docx file lets you edit the content. Programs are built to read specific file types — Word opens .docx files, Excel opens .xlsx files, and your web browser opens .html files. If you try to open a file type your program does not recognize, you will get an error message.

How files are stored on your device

When you save a file, your device writes the data to its storage drive — either a hard drive, solid-state drive (SSD), or flash memory on a phone. The drive is divided into tiny sections, and your file might be scattered across multiple sections. Your operating system keeps track of where all the pieces are and reassembles them when you open the file, so you never have to think about it.

This is why deleting a file does not always erase it permanently. When you delete a file, your device marks the space it occupied as available for new data, but the original data often remains until something else is written over it. This is also why files can become corrupted — if your device loses power while writing a file, or if a program crashes mid-save, the file might be incomplete or unreadable. Most modern devices have safeguards against this, like auto-save features and journaling systems that protect against data loss.

Frequently Asked Questions

What is the difference between a file and a folder?

A file is a container that holds a single piece of data — a document, photo, or video. A folder is a container that holds files and other folders. Think of a file as a piece of paper and a folder as a filing cabinet drawer that holds multiple pieces of paper.

Can I change a file's extension to open it in a different program?

You can rename the extension, but that does not change what the file actually is. If you rename "photo.jpg" to "photo.txt", your computer will try to open it as text, which will show gibberish. The file is still a photo — only the label changed. To convert a file to a different format, you need to open it in the right program and save it as the new type.

Why do some files have names I cannot read or change?

Your operating system uses certain files to run itself, and it protects them so you cannot accidentally delete or modify them. These are called system files. You can usually see them if you turn on the option to show hidden files in your file manager, but you should not change them unless you know what you are doing.

What happens if I run out of storage space?

Your device will stop letting you save new files or install programs. You can free up space by deleting files you no longer need, moving files to an external drive or cloud storage, or uninstalling programs. Most devices will warn you when storage is running low.

Can I recover a file I deleted?

If you deleted a file recently, it may still be in your Recycle Bin (Windows) or Trash (Mac), where you can restore it. If you emptied the trash, recovery is harder but sometimes possible with specialized software, especially if nothing has been written over that space yet. The sooner you try to recover it, the better your chances.