Everything seems to go fine when using memory mapped files, but problem is handle to map is completely empty.

Code:
HANDLE hFile = CreateFile(infile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

HANDLE hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY,  0, filesize, NULL);

PVOID pvFile = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0);

char *temp = (char*) pvFile;

//now trying to write to another file al lthe data
FILE *f = fopen("test.txt","w");
//filesize already obtained and is more than 8 mb
fwrite(temp,1,filesize,f);
fclose(f);

now newly written file is of same size as source, but completely empty, ann bytes are empty.


What may be the problem ?

regards