progressbar problem
-
Hello, I have a problem with the progressbar in the following code: FtpClient ftp = new FtpClient("ftpadres", "user", "password",ttl,21); try { ftp.Login(); } catch (Exception ex) { MessageBox.Show(ex.Message); } ftp.ChangeDir("vrbo"); string fullPath = txtLoggedInSource.Text; string[] dir = fullPath.Split(new Char[] { '\\' }); int length = dir.Length; string directory = dir[length - 1]; ftp.MakeDir(bedrijfid + "_" + directory + "_" + timestamp); ftp.ChangeDir(bedrijfid + "_" + directory + "_" + timestamp); DirectoryInfo dir2 = new DirectoryInfo(txtLoggedInSource.Text); FileInfo[] files = dir2.GetFiles(); int filecount = files.Length; pbStatus.TabIndex = 0; pbStatus.Maximum = filecount; pbStatus.Minimum = 1; pbStatus.Step = 1; /* THIS WORKS PERFECT !!! for (int i = pbStatus.Minimum; i <= pbStatus.Maximum; i++) { pbStatus.PerformStep(); } * */ // HERE THE PROGRESSBAR DOESNT MOVE foreach (FileInfo f in files) { ftp.Upload(txtLoggedInSource.Text + "\\" + f.Name); pbStatus.PerformStep(); } label1.Text = "All files are upload successfully"; ftp.Close(); Can someone please help me why it doesn't work with upload Thx wistiti 5
-
Hello, I have a problem with the progressbar in the following code: FtpClient ftp = new FtpClient("ftpadres", "user", "password",ttl,21); try { ftp.Login(); } catch (Exception ex) { MessageBox.Show(ex.Message); } ftp.ChangeDir("vrbo"); string fullPath = txtLoggedInSource.Text; string[] dir = fullPath.Split(new Char[] { '\\' }); int length = dir.Length; string directory = dir[length - 1]; ftp.MakeDir(bedrijfid + "_" + directory + "_" + timestamp); ftp.ChangeDir(bedrijfid + "_" + directory + "_" + timestamp); DirectoryInfo dir2 = new DirectoryInfo(txtLoggedInSource.Text); FileInfo[] files = dir2.GetFiles(); int filecount = files.Length; pbStatus.TabIndex = 0; pbStatus.Maximum = filecount; pbStatus.Minimum = 1; pbStatus.Step = 1; /* THIS WORKS PERFECT !!! for (int i = pbStatus.Minimum; i <= pbStatus.Maximum; i++) { pbStatus.PerformStep(); } * */ // HERE THE PROGRESSBAR DOESNT MOVE foreach (FileInfo f in files) { ftp.Upload(txtLoggedInSource.Text + "\\" + f.Name); pbStatus.PerformStep(); } label1.Text = "All files are upload successfully"; ftp.Close(); Can someone please help me why it doesn't work with upload Thx wistiti 5
-
Hello, I have a problem with the progressbar in the following code: FtpClient ftp = new FtpClient("ftpadres", "user", "password",ttl,21); try { ftp.Login(); } catch (Exception ex) { MessageBox.Show(ex.Message); } ftp.ChangeDir("vrbo"); string fullPath = txtLoggedInSource.Text; string[] dir = fullPath.Split(new Char[] { '\\' }); int length = dir.Length; string directory = dir[length - 1]; ftp.MakeDir(bedrijfid + "_" + directory + "_" + timestamp); ftp.ChangeDir(bedrijfid + "_" + directory + "_" + timestamp); DirectoryInfo dir2 = new DirectoryInfo(txtLoggedInSource.Text); FileInfo[] files = dir2.GetFiles(); int filecount = files.Length; pbStatus.TabIndex = 0; pbStatus.Maximum = filecount; pbStatus.Minimum = 1; pbStatus.Step = 1; /* THIS WORKS PERFECT !!! for (int i = pbStatus.Minimum; i <= pbStatus.Maximum; i++) { pbStatus.PerformStep(); } * */ // HERE THE PROGRESSBAR DOESNT MOVE foreach (FileInfo f in files) { ftp.Upload(txtLoggedInSource.Text + "\\" + f.Name); pbStatus.PerformStep(); } label1.Text = "All files are upload successfully"; ftp.Close(); Can someone please help me why it doesn't work with upload Thx wistiti 5
You're not giving the form a chance to update itself. See if this works:
foreach (FileInfo f in files) {
ftp.Upload (txtLoggedInSource.Text + "\\" + f.Name);
pbStatus.PerformStep();
Application.DoEvents(); // not this.DoEvents();
}/ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com -- modified at 0:15 Sunday 23rd April, 2006
-
You're not giving the form a chance to update itself. See if this works:
foreach (FileInfo f in files) {
ftp.Upload (txtLoggedInSource.Text + "\\" + f.Name);
pbStatus.PerformStep();
Application.DoEvents(); // not this.DoEvents();
}/ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com -- modified at 0:15 Sunday 23rd April, 2006
-