How to delete all text files from given directory in c++ -
I am trying to determine how to delete all the text files from the given directory. I am using Visual C ++ 2010 Express using Vijapi. I know how to delete the file, if you know the exact name of that file, but I would like to delete all the text files in that directory. This is my latest attempt:
Zero deleteFiles (WCHAR file []) {// WCHAR file [] is actually directory path ie C: \ user \ user / desktop \ folder \ // Characters [MAX_PATH] for four characters for future tasks to charge from WCHAR; Int i; (Int i = 0; file [i]! = '\ 0'; i ++) {// cycle through the array through each letter and place it in the new array file [i] = file [i]; } // Keep blank characters in the end file [i] = '\ 0'; // generated WIN32_FIND_DATA straight and FindFirstFile () WIN32_FIND_DATA fileData; FindFirstFile (file, and file data); // Display the filename message box (tap, file data files, L "check", MB_OK); } The message box only shows the folder that was selected, not the filename. Why is this happening?
A subtle problem is that your two variables get the same names and different With scope: A loop is defined outside and which is unpublished; Others declared inside the loop. The aspects I am referring to are the names i . Because there is no undefined defined outside the loop, when you use it as an index to end the path, its value is uncertain and you have undefined behavior.
Comments
Post a Comment