Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'c++17'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hi, Larry OK'd the posting of this code example which I eventually got to work. The environment was Windows 10, Visual Studio 2017 with the C++17 language in a Windows Form. I wanted to select a directory that had sub-directories and process jpg files in either the top-level directory or and of its sub-directories. I used recursive_directory_iterator to get access to the directories. Here's the code just FYI in case anyone else is crazy enough like me to want to do this. private: System::Void btnSelectDir_Click(System::Object^ sender, System::EventArgs^ e) { // the 'select the root directory' button was clicked FolderBrowserDialog^ folderBrowserDialog1 = gcnew FolderBrowserDialog; directory_list = gcnew List<String^>(20); // initially allow for 20 entries but the capacity will expand automatically if needed directory_count = 0; total_image_files_count = 0; folderBrowserDialog1->SelectedPath = "E:\\Documents\\"; // adjust as necessary // the following control allows the selection of the input root directory System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog(); if (result == System::Windows::Forms::DialogResult::OK) { this->txtDirName->Text = folderBrowserDialog1->SelectedPath; selected_root_directory = folderBrowserDialog1->SelectedPath; // selected_root_directory is a managed string // we have selected a root directory OK // convert it to the format required by recursive_directory_iterator marshal::marshal_context context; // sets the context - needed - but don't know why! std::string unmanaged_selected_path = context.marshal_as<std::string>(selected_root_directory); // Managed string to standard string fs::path selected_path = unmanaged_selected_path; // standard string to path // first see if the selected root directory contains any jpg files - if so add it to the list if (the_directory_contains_at_least_one_jpg_file(selected_path)) { // add the directory to the list directory_list->Add(selected_root_directory); // directory_list has (and needs) global scope directory_count++; } // end the selected root directory contained at least one jpg type file // now see if the selected root directory contains any sub-directories for (auto& p : fs::recursive_directory_iterator(selected_path)) { // 'p' is the path data returned from each iteration - it may reference a sub-directory or a file if (fs::is_directory(p.path())) { // we have a directory std::string path_details = p.path().string(); // convert the path details to a standard string String^ managed_path_details = gcnew String(path_details.c_str()); // convert the standard string to a managed string etc... fs was the namespace I set up for the file system. Cheers from Oz.
×
×
  • Create New...