I made a program, Something very simple to backup 3 folders on my Hard Drive.
I use 3 Check boxes that I click that backups any one of 3 folders.
The problem that I have is that I want the files being copied to get placed into a Text Box or a List View Box. What I click the Backup button. It seems to copy all the files 1st before if it writes them into the Text Box.
I want it to write each file to the text box as it's being copied. Is that even possible.
any one know where I can get some samples using the background worker to copy file and write to a list box. ?
Loading
Kirtan PatelPosted Dec 6, 2009, 10:49 AM
Here is your Solution Please check "Do you like this answer check box if it helps you :)
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
string Foldertobackup = @"E:\backup";
string[] FilesInFolder = Directory.GetFiles(Foldertobackup);
Directory.CreateDirectory(@"D:\BackUpFolderName");
listBox1.Items.Add("Back up Directory Created !!" );
foreach (string file in FilesInFolder)
{
FileInfo f = new FileInfo(file);
File.Copy(file,@"D:\BackUpFolderName\"+f.Name,true);
listBox1.Items.Add(f.Name +"Copied \n\n!!") ;
}
}
private void button1_Click(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
JoePosted Dec 6, 2009, 2:28 PM
Kirtan PatelPosted Dec 6, 2009, 2:03 PM
JoePosted Dec 6, 2009, 1:57 PM
Kirtan PatelPosted Dec 6, 2009, 1:44 PM
Code Copies Only One File at a Time As you can see Processing is Done in Foreach loop that process only one File at time :)
JoePosted Dec 6, 2009, 12:23 PM
JoePosted Dec 6, 2009, 11:53 AM
Kirtan PatelPosted Dec 6, 2009, 11:33 AM
just use single '\' in path
and friend, please check "Do you like this answer" check box :)
JoePosted Dec 6, 2009, 11:26 AM
So I'm lost.
Here's my code below
Can you tell me what I'm going wrong