Opening Existing Files

You can open an existing file by using the OF_READ, OF_WRITE, or OF_READWRITE option. These options direct the OpenFile function to open existing files for reading, writing, or reading and writing. The following example opens the FILE.TXT file for reading:

hFile = OpenFile("FILE.TXT", &OfStruct, OF_READ);

If the file fails to open, you can display a dialog box to indicate that the file was not found. For more information on using OpenFile to prompt for the file, see topic .