How to use DeleteFile with wildcard?
so c:\myFolder\a*.txt will delete a123.txt and a5555.txt but not b123.txt
How to use DeleteFile with wildcard?
so c:\myFolder\a*.txt will delete a123.txt and a5555.txt but not b123.txt
DeleteFile() does not support wildcards.
@user1438233 showed you how to use DeleteFile() in a FindFirstFile() loop to search for files using wildcards.
Another option is to use SHFileOperation() and let the Shell handle the wildcards for you:
SHFILEOPSTRUCTW op = {0}; op.wFunc = FO_DELETE; op.pFrom = L"C:\\myFolder\\a*.txt\0"; op.fFlags = FOF_FILESONLY | FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NORECURSION; SHFileOperationW(&op);