winapi - Issue Deleting documents using wildcards in C++ Builder 6 -


i'm using function delete files if there's wild card involved made application in c++ builder 6 reads file commands , execute them problem when put different directory function reads , delete file commands example file hola.txt

when ofstream("hola2.txt") or ofstream ("c:\path\hola3.txt"), works fine when comes delete use remove("hola.txt") works can't use wildcards 1 if wilddeletefiles("*.txt") deletes every txt file in application folder when wilddeletefiles("c:\path*.txt") doesn't delete txt file in directory instead erase txt file commands function

void wilddeletefiles(const char* direcc) {     win32_find_data fd;     handle hfind;      hfind = findfirstfile(direcc, &fd);     if (hfind == invalid_handle_value)     {         showmessage("no files found!");     }     else     {                 {             deletefile(fd.cfilename);         }         while (findnextfile(hfind, &fd));         showmessage("files deleted!");         cmpi++;         rfi = 1;     } } 

and how call later:

void __fastcall tform1::image4click(tobject *sender) {     wilddeletefiles(tstrings1->cells[1][0].c_str()); } 

what doing wrong?

two things:

  • firstly, ide use horribly outdated , won't find support today. should upgrade.
  • secondly, don't check errors @ all, isn't good. if step through code , check against documentation, find findfirstfile()/findnextfile() it's documented do, in particular doesn't recursive search files. if want that, either implement or use shell functions shfileoperation(). in case, searching "windows c++ delete file tree" should give bunch of hints look.

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -