// Delete a file or folder Bool Deletefile ( String Strpath ){ Int Nlen = Strpath. Length (); Char * Ppath = New Char [Nlen + 2 ]; Strcpy (ppath, strpath. c_str (); ppath [nlen + 1 ] = ' \ 0 ' ; Shfileopstruct fileop = { 0 }; Fileop. fflags = // Fof_allowundo | // Allow reuse to recycle bin Fof_noconfirmation | // No confirmation dialog box appears Fof_noerrorui; // No error dialog box appears Fileop. pfrom = Ppath; fileop. PTO = NULL; // It must be null. Fileop. wfunc = fo_delete; // Delete operation Bool Bresult = (shfileoperation (& fileop) = 0 ); Delete [] ppath; Return Bresult ;} // Copy a file or folder Bool Copyfile ( String Strfrom, String Strto ){ Int Nfromlen = Strfrom. Length (); Int Ntolen = Strto. Length (); Char * Pfrom = New Char [Nfromlen + 2 ]; Char * PTO = New Char [Ntolen + 2 ]; Strcpy (pfrom, strfrom. c_str (); strcpy (PTO, strto. c_str (); pfrom [nfromlen + 1 ] = ' \ 0 ' ; PTO [ntolen + 1 ] = ' \ 0 ' ; Shfileopstruct fileop = { 0 }; Fileop. fflags = Fof_noconfirmation | // No confirmation dialog box appears Fof_noconfirmmkdir; // Create a folder directly when needed, without user confirmation Fileop. pfrom = Pfrom; fileop. PTO = PTO; fileop. wfunc = Fo_copy; Bool Bresult = (shfileoperation (& fileop) = 0 ); Delete [] pfrom; Delete [] PTO; Return Bresult ;} // Move a file or folder Bool Movefile ( String Strfrom, String Strto ){ Int Nfromlen = Strfrom. Length (); Int Ntolen = Strto. Length (); Char * Pfrom = New Char [Nfromlen + 2 ]; Char * PTO =New Char [Ntolen + 2 ]; Strcpy (pfrom, strfrom. c_str (); strcpy (PTO, strto. c_str (); pfrom [nfromlen + 1 ] = ' \ 0 ' ; PTO [ntolen + 1 ] = ' \ 0 ' ; Shfileopstruct fileop = {0 }; Fileop. fflags = Fof_noconfirmation | // No confirmation dialog box appears Fof_noconfirmmkdir; // Create a folder directly when needed, without user confirmation Fileop. pfrom = Pfrom; fileop. PTO = PTO; fileop. wfunc = Fo_move; Bool Bresult = (shfileoperation (& fileop) = 0 ); Delete [] pfrom; Delete [] PTO; Return Bresult ;} // From a named file or folder Bool Renamefile ( String Strfrom, String Strto ){ Int Nfromlen = Strfrom. Length (); Int Ntolen = Strto. Length (); Char * Pfrom = New Char [Nfromlen + 2 ]; Char * PTO = New Char [Ntolen + 2 ]; Strcpy (pfrom, strfrom. c_str (); strcpy (PTO, strto. c_str (); pfrom [nfromlen + 1 ] = ' \ 0 ' ; PTO [ntolen + 1 ] =' \ 0 ' ; Shfileopstruct fileop = { 0 }; Fileop. fflags = Fof_noconfirmation; // No confirmation dialog box appears Fileop. pfrom = Pfrom; fileop. PTO = PTO; fileop. wfunc = Fo_rename; Bool Bresult = (shfileoperation (& fileop) = 0 ); Delete [] pfrom; Delete [] PTO; Return Bresult ;}
The shfileoperation operation requires two '\ 0' relative paths, for example, ".. \ x. xml \ 0", including its own \ 0
Additional reading: http://www.vcsos.com/article/pageSource/120216/20120216083823.shtml