Get total number of files in a folder in Windows (C++/MFC)
Code to get total number of files in a folder in Windows (C++/MFC). int GetTotalFiles(CString folderPath) { if (!PathFileExists(folderPath)) return 0; CFileFind finder; CString findString; CString...
View ArticleDelete oldest file from a folder on Windows in C++/MFC
Following code deletes the oldest file from a folder. We need this when we wish to keep last X copies of a file for backup. So we would just delete the oldest one and create a new backup copy. Coded...
View ArticleDelete a folder even if not empty in Windows (C++/MFC)
Following is the code to delete a directory folder even if it is not empty in Windows. Coded in C++/MFC. BOOL DeleteFolder(CString strFolder, BOOL bDeleteIfNotEmpty ) { BOOL bRet = FALSE; int...
View ArticleCopy or move files using wildcards to another folder in Windows (C++/MFC)
The following function uses SHFileOperation Windows API to copy multiple files using wildcards to another folder. It has option to delete files from source location too (Whether to copy or to move the...
View ArticleDelete multiple files using wildcards in Windows (C++/MFC)
Following code uses SHFileOperation Windows API to delete multiple files using wild card (silently without any confirmation box). It deletes only files. Not folders. Coded in C++/MFC. BOOL...
View ArticleGet path with unique file name in Windows (C++/MFC)
Sometimes, when a file with same name already exists, we wish to generate a new unique file name. The following function does this. Coded in C++/MFC. A number is suffixed to the file name. You can...
View ArticleRemove invalid characters from a file name in Windows (C++/MFC)
In Windows, a file or folder name cannot contain the following characters \/:*?\”| . Sometimes before saving a file, you may want to remove these invalid characters from the file name. Here is the...
View ArticleGenerate a temporary file path with a temp file name in Windows (C++/MFC)
Following function creates a temporary file path with a specific file extension. Optionally, it also creates the temporary file. Coded in C++/MFC (Windows). CString GenerateTempFilePath(BOOL...
View ArticleRemove duplicates from string array in Windows (C++/MFC/ATL)
Following code removes duplicates from string array in Windows (C++/MFC/ATL). void RemoveDuplicatesFromArray(CAtlArray<CString> &arrValue) { CAtlArray<CString> arrNew; INT_PTR i, j,...
View ArticleLoad binary file into buffer in Windows (C++/MFC)
Following is the function to load a binary file into a memory buffer in Windows (C++/MFC). //Do not use this for text files as the following code doesn't handle UTF, UNICODE, BOMLESS etc. BOOL...
View Article
More Pages to Explore .....