Error with Memory Mapped File

  • Thread starter Vinh Nguyen Van
  • Start date
V

Vinh Nguyen Van

Dear Alex Yakhnin
I has downloaded your source code for Memory Mapped File.
I create a sample:
private static void Test(string fileName)
{
MemoryMappedFileStream mStream = new
MemoryMappedFileStream(fileName, "a", 64,
MemoryProtection.PageReadOnly);
byte[] bff = new byte[10];
mStream.Read(bff, 0, 10);
Console.WriteLine();
}
I debug from source code, I see that:
IntPtr hFile = MemoryMappedFileHelper.CreateFileForMapping(fileName,
Win32FileAccess.GENERIC_READ | Win32FileAccess.GENERIC_WRITE,
Win32FileShare.FILE_SHARE_READ | Win32FileShare.FILE_SHARE_WRITE,
IntPtr.Zero, Win32FileMode.OPEN_ALWAYS,
Win32FileAttributes.FILE_ATTRIBUTE_NORMAL, IntPtr.Zero);

uint lastError = MemoryMappedFileHelper.GetLastError();

lastError = 183

When I continue my app to get some bytes from mapped memory, my app
close automatically.

I develop on C#, NetFX 2.0, pocket pc 2003.
Help me please.
Thanks
 
G

Guest

Don't address posts to an individual - this is a newsgroup, not a chat room.

Error 183 (you should learn to look those up) is "Cannot create a file when
that file already exists." My guess is that the file is open by something
else that didn't give compatible sharing when it opened it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top