Quantcast
Channel: Gautam Jain's Blog
Browsing latest articles
Browse All 50 View Live

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 Article



Delete 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 Article

Delete 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 Article

Copy 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 Article

Delete 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 Article


Get 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 Article

Remove 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 Article

Generate 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 Article


Remove 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 Article


Load 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
Browsing latest articles
Browse All 50 View Live




Latest Images