ocu_delete_files

 

Description

Delete multiple files in the specified path.

Syntax

int ocu_delete_files( LPCSTR lpcszPath, LPCSTR lpcszNamePattern = NULL, StringArray * pcsaFileSkip = NULL )

Parameters

lpcszPath
[input] file path for deleting files
lpcszNamePattern
[input] filename pattern, wildcard characters * and ? can be used
pcsaFileSkip
[input] optional list of files (by name, no wildcard) to indicate not to delete

Return

number of files deleted, or < 0 for errors

Examples

EX1

#include <ocu.h>
//Notes: Deleted files can not be recovered, so be careful while using this method.
void ocu_delete_files_ex1()
{
        string strPath = GetAppPath(true) + "OriginC\\System\\";
        int nNum = ocu_delete_files(strPath, "*.OPH"); //delete all files with extension name as OPH
        if ( nNum < 0 )
                out_str("Error occurs while trying to delete files.");
        else
                printf("%d files deleted under path %s\n", nNum, strPath);
}

Remark

See Also

header to Include

ocu.h

Reference