Solved

Display name of file being copied to UI using copyDir

Posted on 2011-09-02
3
272 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
Comment Utility
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)
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now