10.1 Overview

File input and output in Windows-based applications are similar to file input and output in standard C run-time applications. However, there are enough differences between the two systems to make a review of file input and output important. For example, although you can use C run-time stream input and output (I/O) functions in Windows, it is preferable to use the low-level, C run-time input and output functions. Also, since Windows is a multitasking operating system, you must manage open files carefully.

In Windows, applications that do not use the common dialog boxes should use the OpenFile function to work with files. OpenFile opens and manages files, returning a file handle that you can use with the low-level C run-time functions to read and write data.

This chapter covers the following topics:

Handling files in the Windows operating system

Using the OpenFile function to create, open, close, reopen, prompt for, and check the status of disk files

Using the low-level, C run-time input and output functions to read from and write to disk files

This chapter also explains how to create a sample application, EditFile, that illustrates some of these concepts.