There are few ways to do it, depends on how far you want to go, if you want to delete duplicated files from one specific folder, or files from a tree of folders, this last it's harder but possible. Then if you want to use name and size to compare, or, convert the file to binary and compare, this will only remove files that are equal in every single line, blank space, etc.
I already worked with files and folders, for FTP and binary convertion for encryption, all of this in C++.