// Boosttest. cpp: defines console applications. Program . // # Include "stdafx. H "# include" Boost/filesystem. HPP "// includes all needed boost. filesystem declarations # include <iostream> // for STD: coutusing namespace boost: filesystem; using namespace STD; # include <boost/filesystem. HPP> # include <vector> # include <string> # include <iostream> namespace FS = boost: filesystem; void getallfileofpath (STD: String strpath, STD :: vector <STD: String> & dllnames) {FS: path F Ullpath (FS: initial_path (); // initialize this project path fullpath = FS: system_complete (FS: path (strpath, FS: Native )); // convert relative paths to absolute paths // Note: fullpath is feasible if (! FS: exists (fullpath) // check whether the specified directory exists {STD: cout <"cannot be found. Check whether the directory exists:"; STD :: cout <fullpath. native_file_string () <STD: Endl; // output path name return;} If (! FS: is_directory (fullpath) // whether the directory is {STD: cout <"the specified path is not a directory"; STD: cout <fullpath. native_file_string () <STD: Endl; return;} FS: directory_iterator end_iter; For (FS: directory_iterator file_itr (fullpath); file_itr! = End_iter; ++ file_itr) {If (! FS: is_directory (* file_itr) & (FS: Extension (* file_itr )! = ". EXE ") // file suffix {dllnames. push_back (file_itr-> leaf (); // get file name }}int main () {try {string P ("C: /tddownload/Yue Quan Chuan/fdsaf "); STD: vector <STD: String> dllnames; getallfileofpath (p, dllnames); STD :: vector <STD: String >:: iterator itr = dllnames. begin (); For (; itr! = Dllnames. end (); ++ itr) {STD: cout <* itr <STD: Endl; remove (p + "/" + * itr );}} catch (exception & E) {cout <E. what () <Endl ;}}