This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

get path and filename of all files in a given dir and its subdirs using c++ (builder)

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.79 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void AddFiles(AnsiString path/*, TDataSet *DataSet*/)
  2. {
  3. TSearchRec sr;
  4. int f;
  5.     f = FindFirst(path+"\*.*", faAnyFile, sr);
  6.     while( !f )
  7.     {
  8.         if(sr.Attr & faDirectory)
  9.         {
  10.                         if(sr.Name != "."   &&   sr.Name != "..")
  11.                         {
  12.                                         path.sprintf("%s%s%s", path, "\", sr.Name);
  13.                                         AddFiles(path/*, DataSet*/);
  14.                         }
  15.         }
  16.         else
  17.         {
  18.                         Form1->ListBox1->Items->Add(path+ "\"+ sr.Name);
  19.                         //DataSet->Append();
  20.                         //DataSet->FieldByName("Name")->Value = sr.Name;
  21.                         /* other fields ... */
  22.                         //DataSet->Post();
  23.         }
  24.         f = FindNext(sr);
  25.     }
  26.     FindClose(sr);
  27. }
  28.        
  29. path.sprintf("%s%s%s", path, "\", sr.Name);
  30. AddFiles(path/*, DataSet*/);
  31.        
  32. AnsiString subpath;
  33. subpath.sprintf("%s%s%s", path, "\", sr.Name);
  34. AddFiles(subpath/*, DataSet*/);
clone this paste RAW Paste Data