Hi,
I am exporting a function from vc++ DLL to write to a binary file. In the C++ code the file is opened using
FILE* fp = ::_tfopen (FilePath, _T("a+b"));
I a using the "a+b"
mode to append the file later on and b is for the binary mode.
Now I am importing this function in my C# application. When I make a call to this function from C# with the right arguments, the file gets written but not in append mode. What I mean is that the function opens the file but doesnt seem to append to its contents , instead it destroys its contents and then writes whatever my C# arguments are.
Platform is VS2005. Any help please?
- Thanks Viren
Imported from comments
[DllImport("NameOfTheDLL.dll", CharSet = CharSet.Ansi)]
public static extern int function_name(IntPtr ptr,
[MarshalAs(UnmanagedType.LPWStr)] string FilePath);
Following is the call to the function:
IntPtr ptr = some_Init_function();
function_name(handle, "C:\\FileName");