The strangeness of the CfileFind class in the MFC

xiaoxiao2021-03-05  25

When I use the MFC's CFILEFIND Find file, get the next file using getNextFile (). After the processing is completed, you remove the file. When there is a file, it should return True, then you can use getFileName to get the file name, path, but not completely. In the search position, when there is a file match, getNextFile () will return false, and getLastError () will get ERROR_NO_MORE_FILES, if processed, you can also get the file name of this last file, after processing, if you continue If the getNextFile returns or false, this is good, but use GetFileName, it will also get a file name, but not correct, because getFileName returns the cstring type, in the system run, you may also store files in front The name of memory is not cleared, and the file name has been processed. This is wrong. About GetNextFile, MSDN is a little: Nonzero if The File Found is The Last One in The Directory or if An Error Occurred. Possible reasons are: cfilefind may not support its search directory dynamic changes, from start searching, to last processing, the files of the directory should not change.

转载请注明原文地址:https://www.9cbs.com/read-31794.html

New Post(0)