I have made a program which takes some files, renames them to a random number and then saves it to a different folder. I managed to make the code do what I wanted, however the files it handles are sometimes quite large and take a while. This means the users sometimes think that the program has crashed.
I would like to add a progress bar to the program, to make it obvious that it's still working and not crashed.
I had a look at another question on how to add a progress bar, however in my case the function takes an intake, which depends on the button the user clicks.
I'm unsure how I could add it into my code. Ideally I could have the backgroundWorker_DoWork take an additional input, so it would be (object sender, DoWorkEventArgs e, string[] Files), but it doesn't seem to be possible.
Any help would be greatly appreciated.
The code for the relevant functions is below:
private void blindSelected_Click(object sender, EventArgs e)
    {
        List<string> toBlind = new List<string>();
        // Find all checked items
        foreach (object itemChecked in filesToBlind.CheckedItems)
        {
            toBlind.Add(itemChecked.ToString()); 
        }
        string[] arrayToBlind = toBlind.ToArray();
        blind(arrayToBlind);
    }
    private void blindAll_Click(object sender, EventArgs e)
    {
        List<string> toBlind = new List<string>();
        // Find all items
        foreach (object item in filesToBlind.Items)
        {
            toBlind.Add(item.ToString());
        }
        string[] arrayToBlind = toBlind.ToArray();
        blind(arrayToBlind);
    }
    private void blind(string[] files)
    {
            // Generate an integer key and permute it
            int[] key = Enumerable.Range(1, files.Length).ToArray();
            Random rnd = new Random();
            int[] permutedKey = key.OrderBy(x => rnd.Next()).ToArray();
            // Loop through all the files
            for (int i = 0; i < files.Length; i++)
            {
                // Copy original file into blinding folder and rename
                File.Copy(@"C:\test\" + files[i], @"C:\test\blind\" + permutedKey[i] + Path.GetExtension(@"C:\test\" + files[i]));
            }            
            // Show completed result
            MessageBox.Show("Operation complete!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
 
     
    