1. Introduction to Files
A file is an object that is used to store data. Files can contain all sorts of data, from images to spreadsheets to executable programs.
Files are stored on secondary storage media, for example, hard disk, external hard drive, CD, flash memory stick etc.
Every file is given a name when it is created, and usually, an extension, telling the computer and the user what type of data the file contains.
MyText.txt (contains text data) MyPic.jpg (contains image data) MyMusic.mp3 (contains music or sound data) MyMovie.mpg (contains video and audio data)
Files do not have to have extensions, technically you can still open them. However if you don't know the correct file format and try to open it with an incompatible application, then all you will see is garbage.
There are many other standard file types. Standard file types (such as mp3) can be used by hundreds of different applications because the file data format has been made public.
However it is also perfectly possible to create a custom file type with your own software program and give it an unique extension such as
The software that created the MySpecialFile.mine will have formatted the data just the way it needs.
In the following pages, we will discuss how files can be opened, closed, read, and written to by a programmer.