Hello,

Web programmer in need of some windows app help. I have a simple little program that copies files from drive X to drive Y, and dumps the success/failure messages into a multiline textbox. The problem I'm having however is that the textbox does not update until all the copy functions complete. I was hoping to have it update in real-time, such as after each copy success failure.


code looks like the following:

public Form1()
        {
            InitializeComponent();
            this.Show();

            lblCloseMessage.Visible = false;


            tbxOutput.Text = "Program Starting at...\r\n";
            StartJob();
            WriteMessageToLogFile(tbxOutput.Text);
        }

protected void StartJob()
        {
            MakeFolders();

            NetworkDrive oNetDrive = new aejw.Network.NetworkDrive();
            if(Connect(ref oNetDrive))
            {
                CopyFiles();
                tbxOutput.Text += "\r\n\r\n";

                Copy837Files();
                tbxOutput.Text += "\r\n\r\n";
                Distribute837Files();
                tbxOutput.Text += "\r\n\r\n";
                DistributeFilesToFolder("H*.DAT", DestinationFolders[0]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("H*.DAT", DestinationFolders[1]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("H*.DAT", DestinationFolders[2]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("H*.DAT", DestinationFolders[3]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("H*.DAT", DestinationFolders[5]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("E*.DAT", DestinationFolders[0]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("E*.DAT", DestinationFolders[1]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("E*.DAT", DestinationFolders[5]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("J*.DAT", DestinationFolders[0]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("J*.DAT", DestinationFolders[2]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("B*.DAT", DestinationFolders[0]);
                tbxOutput.Text += "\r\n\r\n";

                DistributeFilesToFolder("B*.DAT", DestinationFolders[4]);
                tbxOutput.Text += "\r\n\r\n";

                CleanupTempFolder();
                
            }
            try
            {
                Disconnect(ref oNetDrive);
            }
            catch
            {
            }
            
        }

I can't for the life of me figure out how to get the textbox to update after each DistributeFilesToFolder() call (which dumps text into the textbox). Any help would be greatly appreciated. Thanks!

-David

You could try using Applications.DoEvents();. That will force the form and all of its controls to be redrawn.

yo could also have done the copying asynchronously and then used update panels to update the textbox :D

This question has already been answered. Start a new discussion instead.