为何文件在先写了后再去读,就读不出写之后的文件内容了?代码:
 hFile = CreateFile("D:\myFile.TXT",GENERIC_WRITE | GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
  if( hFile == INVALID_HANDLE_VALUE)
  {
MessageBox(hwnd,"文件创建失败!","Note",MB_OK);
return -1;
  }   strcpy(writeBuffer,"我们mmmmmm失败");
if(!WriteFile(hFile,writeBuffer,strlen(writeBuffer),&nByteswritten,NULL))
  {
      MessageBox(hwnd,"write fail!","Note",MB_OK);
  break;
 }
  nFileSize = GetFileSize(hFile,NULL);
  if(!ReadFile(hFile,readBuffer, nFileSize,&nBytesRead,0))
  {
  MessageBox(hwnd,"read fail!","Note",MB_OK);
  break;
  }
  else
  {
  readBuffer[4]='\0';
  MessageBox(hwnd,readBuffer,"Note",MB_OK);
  }
  break;