I have a piece of code which is moved to .NET VC7 recently from VC6 and there
has been an apparent change in behavior using CreateFile/Writefile
functionality.
I am creating a file on a shared drive using the win32 Api and using the
handle returned, i call writefile giving number of bytes to write as 1MB.
Shared directory on the machine maps to F: drive ( "shared" is the directory
name maps to " F:")
In VC6 on executing CreateFile("//mymachinename/shared/abcd.txt", ... )
My process gets the file handle which points to the absolute path of the
file i.e.
F:/abcd.txt . In FileMon ( sysinternals.com) i get IRP_MJ_WRITE done by my
process each with 1MB size. Using the same code in .NET with the same
parameters to CreateFile, my process get the handle to the file as
/device/lanmanredirector/mymachinename/shared/abcd.txt while system process
gets the handle to F:/abcd.txt. On executing WriteFile, ( In FileMon) i see
that its the system process who takes the ownership of the writes and writes
are happening in chunks of 20 - 40k which is killing the performance.
A hack - If i give absolute path to Createfile("F:/abcd.txt", ..), my
process gets the correct handle and i am able to do 1 MB writes.
Query : - Are there any specific compiler settings/ registry settings which
needs to be changed to get the desired results with the original code.
Thanks
Nitin