Hi guys,
I am trying to use windows API writefile in c#.
my problem is after I write something to the file, it does not increase the file pointer and so if I write something else it rewrite it!!
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile);
[DllImport("kernel32.dll", BestFitMapping = true, CharSet = CharSet.Ansi)]
public static extern bool WriteFile(
IntPtr hFile,
System.Text.StringBuilder lpBuffer,
uint nNumberOfBytesToWrite,
out uint lpNumberOfBytesWritten,
[In] ref System.Threading.NativeOverlapped lpOverlapped);
_FileHandle = CreateFile(_CSVFileName, 0x40000000, 0x00000001, IntPtr.Zero, 4, 0x00000080, IntPtr.Zero);
WriteFile(_FileHandle, oSTR, LenToWrite, out LenWritten, ref OverLap);
For some reasons I do not want to use system.IO.*
(I have a problem using system.io.* -my previous question- )
what am I doing wrong?!
Thanks.
re-tagged as c# only.
-Emilio-