Solved

Display name of file being copied to UI using copyDir

Posted on 2011-09-02
3
277 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

840 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