winapi - How do I call the ReplaceFile function from C#? -


i have googled lot , couldn't find solution, posting here. microsoft document

bool winapi replacefile(       _in_       lpctstr lpreplacedfilename,       _in_       lpctstr lpreplacementfilename,       _in_opt_   lpctstr lpbackupfilename,       _in_       dword   dwreplaceflags,       _reserved_ lpvoid  lpexclude,       _reserved_ lpvoid  lpreserved     ); 

i need implement in c# basic structure.

[dllimport("kernel32", setlasterror = true)]     private static extern bool replacefile(        ///argument implemetation here     ); 

but don't know how implement arguments in c#. googled lot didnt solution. can me on this?

according pinvoke.net info on replacefile, need:

[dllimport("kernel32.dll", setlasterror=true, charset=charset.auto)] static extern bool replacefile(    string           lpreplacedfilename,    string           lpreplacementfilename,     string           lpbackupfilename,     replacefileflags dwreplaceflags,     intptr           lpexclude,     intptr           lpreserved);  [flags] enum replacefileflags : uint {     replacefile_write_through       = 0x00000001,     replacefile_ignore_merge_errors = 0x00000002,     replacefile_ignore_acl_errors   = 0x00000004, } 

just pass intptr.zero last 2 parameters. according sdk documentation, not used. same documentation explain purpose of other parameters.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -