V
Vlad
I'll do a mappig of a big file using a paging for reader it.
The first time I call CreateFileMapping and MapViewOfFile with a page
of 655360, the pointer is not null; then I want to read another page
and I used UnmapViewOfFile, CloseHandle and callback MapViewOfFile.
but the pointer is null.
The method that make a new paging:
public int MapFile(long offSet)
{
IntegerType iType=new IntegerType();
//The start address of the new page
long _addrStart;
_addrStart =(long) (Math.Ceiling((decimal)((offSet)
/ _pageSize))) * _pageSize;
if (_pTofile.ToPointer() != null)
{
//Dispose
Winapi.UnmapViewOfFile(_pTofile);
_pTofile = new IntPtr(null);
//Winapi.CloseHandle(_hMap);
//_hMap = new IntPtr(null);
}
else
_hMap =
Winapi.CreateFileMapping(_hFile.DangerousGetHandle(), IntPtr.Zero,
Winapi.myEnumProtect.PAGE_READONLY, 0,
(int)_sFile,
indexFile.ToString());
indexFile++;
_pTofile = Winapi.MapViewOfFile(_hMap,
Winapi.myenumFileMap.FILE_MAP_READ,
iType.HIWORD(_addrStart),
iType.LOWORD(_addrStart),
(int)_pageSize);
}
It's corret the dispose methods
Can someone help me? Thanks
The first time I call CreateFileMapping and MapViewOfFile with a page
of 655360, the pointer is not null; then I want to read another page
and I used UnmapViewOfFile, CloseHandle and callback MapViewOfFile.
but the pointer is null.
The method that make a new paging:
public int MapFile(long offSet)
{
IntegerType iType=new IntegerType();
//The start address of the new page
long _addrStart;
_addrStart =(long) (Math.Ceiling((decimal)((offSet)
/ _pageSize))) * _pageSize;
if (_pTofile.ToPointer() != null)
{
//Dispose
Winapi.UnmapViewOfFile(_pTofile);
_pTofile = new IntPtr(null);
//Winapi.CloseHandle(_hMap);
//_hMap = new IntPtr(null);
}
else
_hMap =
Winapi.CreateFileMapping(_hFile.DangerousGetHandle(), IntPtr.Zero,
Winapi.myEnumProtect.PAGE_READONLY, 0,
(int)_sFile,
indexFile.ToString());
indexFile++;
_pTofile = Winapi.MapViewOfFile(_hMap,
Winapi.myenumFileMap.FILE_MAP_READ,
iType.HIWORD(_addrStart),
iType.LOWORD(_addrStart),
(int)_pageSize);
}
It's corret the dispose methods
Can someone help me? Thanks