Reading from and Writing to a File

Once you open or create a file with CreateFile, use the returned file handle to gain access to the file. Windows CE maintains a file pointer to read and write data between a file and a buffer. When you open a file for the first time, Windows CE places the file pointer at the beginning of the file. Windows CE advances the file pointer after reading or writing each byte between the buffer and the file.

Accessing the data buffer while Windows CE is performing a read or write operation with that buffer might lead to data corruption. Therefore, be sure that you do not modify a data buffer currently in use by a read or write operation. If you use multiple threads or semaphores, be sure that one thread does not access the data buffer while another thread performs a read/write operation.