Solved

Display name of file being copied to UI using copyDir

Posted on 2011-09-02
3
276 Views
Last Modified: 2013-12-17
Experts,

I have a C#  Win Form app that uses a background worker and copyDir to copy all the contents of one directory to another. When debugging the Output console prints a nice list of the current file being copied. I'd like to display this info to the user so they can see the progress in addition to the progress bar I'm using. Currently in my backgound worker DoWork method I have the following:

try
            {
                copyDir mycopy = new copyDir();
                myAnswer = mycopy.CopyAll(dir1, dir2);
               
            }
            catch
            {
                bwWork.CancelAsync();
                MessageBox.Show("Could not find thumb drive", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

Can this be done?

Thanks!
0
Comment
Question by:lateapex
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 36477567
what is the definition of the CopyDir class ?

it must be writing to Debug and probably can be moded to Copy to a status bar or similar.
(copyDirectory is part of System namespace.)
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 36477588
on the assumption you are using http://channel9.msdn.com/Forums/TechOff/257490-How-Copy-directories-in-C

you will see it has a Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);

that writes the name of each file to the output window. If this were a console (ir command prompt app), you would see this is final product. But would be hard (at least for me) to modify so that it shows in a progress dialog.

http://www.codeproject.com/KB/files/Copy_files_with_Progress.aspx may be more what you are seeking as it appears to allow use of a special progress dialog that can display the full path and filename being actioned.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question