Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8813199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:47:10+00:00 2026-06-14T03:47:10+00:00

I have been writing a c++ code for myself,which iterates in a directory and

  • 0

I have been writing a c++ code for myself,which iterates in a directory and will move files in to a directory of the same name as the file

   \\\\
           void foldersFrame::OnButton2Click(wxCommandEvent& event)
            {
                wxFileName mkr;
                StaticText1->SetLabel(_("0"));
                wxString fn;
                wxString newf;
                wxDir *dir=new wxDir(TextCtrl1->GetLabel());
                bool cont = dir->GetFirst(&fn);
                while (cont)
                {
                    int mm=fn.Find('.',true);
                    newf=fn.Mid(0,mm);
                    if(! mkr.DirExists(dir->GetName()+_("\\")+fn)){
                        StaticText2->SetLabel(_("copying  ")+fn);
                        if (! mkr.DirExists(dir->GetName()+_("\\")+newf)){
                            mkr.Mkdir(dir->GetName()+_("\\")+newf);
                            if (wxCopyFile(dir->GetName()+_("\\")+fn,dir->GetName()+_("\\")+newf+_("\\")+fn)){
                                wxRemoveFile(dir->GetName()+_("\\")+fn);
                            }
                            newf=StaticText1->GetLabel();
                            long d1;
                            if(!newf.ToLong(&d1));
                            d1+=1;
                            StaticText1->SetLabel(wxString::Format(wxT("%i"),d1));
                        }
                    }
                    cont = dir->GetNext(&fn);
                }
                wxSafeShowMessage(_("Message"),_("Finished"));
            }

But the code i have written seem to be very inefficient.It takes a lot of time to move files,and the window doesn’t respond while copying.Someone please help me rewrite it..!!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:47:11+00:00Added an answer on June 14, 2026 at 3:47 am

    You have two standard ways to implement a long running task.

    First one, and by far the best, is to perform this task in a separate background thread. You can update the state of the GUI controls in the main thread by posting wxThreadEvent containing the progress data to the main window easily. The only complication — but a pretty important one — in this case is to handle closing the window/application termination/thread exit correctly.

    Second one, which could do in a pinch, is to do the task in wxEVT_IDLE handler piece by piece and call wxIdleEvent::RequestMore() after each step. This is not as responsive as using a separate thread because you still block the event handling during the handler execution and the code needs to be rewritten in a different way to be able to resume from where it left off.

    Using wxYield() is a pretty bad idea and should be avoided unless no other solution can be implemented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing some code to create a byte array I will be
I have been writing Python code for only a couple of weeks, so I'm
I have been writing unit tests using NUnit and Moq with my Silverlight code
I have been messing around with writing some stored procedures in .NET code with
I have been writing DLL on C++, that will be use in C#. DLL
Folks, I've been writing some code in Scala lately to teach myself the language
I have been writing code without realizing WHY I can access constant values within
I have been writing C code for many years, but I recently came accross
I have a weird question. I have been writing a code to change the
I have been writing linear winforms for couple of months and now I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.