|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Copying files with progress barI use system.io.file class to copy files but i have a difficulty about implementing a basic / XP-like progress bar indicator during copying process. My code is this with no progress bar, or i couldn't find sth which give totalbytes/written bytes class. And does system.io.file class provide awaring of the chunks / bytes of the files bytes which are written? Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If opendlg.ShowDialog = Windows.Forms.DialogResult.OK Then TextBox1.Text = opendlg.FileName End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If savedlg.ShowDialog = Windows.Forms.DialogResult.OK Then TextBox2.Text = savedlg.FileName End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click File.Copy(TextBox1.Text, TextBox2.Text) End Sub End Class Kimi,
What you are doing is let the OS copy the two files for you. There is in no way something that is usable for a progressbar for it. Using a progressbar would even very much slow down the process. That is why you see often in this kind of operations an avi or gif rolling in a picturebox. I did not check it, however probably is this avi in the SDK of your visual studio. Cor Show quoteHide quote "kimiraikkonen" <kimiraikkone***@gmail.com> schreef in bericht news:5d0c620c-ffeb-4dca-a790-f56461d3a93f@o42g2000hsc.googlegroups.com... > Hi, > I use system.io.file class to copy files but i have a difficulty about > implementing a basic / XP-like progress bar indicator during copying > process. > > > My code is this with no progress bar, or i couldn't find sth which > give totalbytes/written bytes class. And does system.io.file class > provide awaring of the chunks / bytes of the files bytes which are > written? > > Imports System.IO > Public Class Form1 > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button1.Click > If opendlg.ShowDialog = Windows.Forms.DialogResult.OK Then > TextBox1.Text = opendlg.FileName > End If > End Sub > > Private Sub Button2_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button2.Click > If savedlg.ShowDialog = Windows.Forms.DialogResult.OK Then > TextBox2.Text = savedlg.FileName > End If > End Sub > > Private Sub Button3_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button3.Click > File.Copy(TextBox1.Text, TextBox2.Text) > End Sub > End Class
Show quote
Hide quote
On Nov 27, 8:24 pm, "Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> Hi Cor,wrote: > Kimi, > > What you are doing is let the OS copy the two files for you. There is in no > way something that is usable for a progressbar for it. > > Using a progressbar would even very much slow down the process. That is why > you see often in this kind of operations an avi or gif rolling in a > picturebox. I did not check it, however probably is this avi in the SDK of > your visual studio. > > Cor > > "kimiraikkonen" <kimiraikkone***@gmail.com> schreef in berichtnews:5d0c620c-ffeb-4dca-a790-f56461d3a***@o42g2000hsc.googlegroups.com... > > > Hi, > > I use system.io.file class to copy files but i have a difficulty about > > implementing a basic / XP-like progress bar indicator during copying > > process. > > > My code is this with no progress bar, or i couldn't find sth which > > give totalbytes/written bytes class. And does system.io.file class > > provide awaring of the chunks / bytes of the files bytes which are > > written? > > > Imports System.IO > > Public Class Form1 > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e > > As System.EventArgs) Handles Button1.Click > > If opendlg.ShowDialog = Windows.Forms.DialogResult.OK Then > > TextBox1.Text = opendlg.FileName > > End If > > End Sub > > > Private Sub Button2_Click(ByVal sender As System.Object, ByVal e > > As System.EventArgs) Handles Button2.Click > > If savedlg.ShowDialog = Windows.Forms.DialogResult.OK Then > > TextBox2.Text = savedlg.FileName > > End If > > End Sub > > > Private Sub Button3_Click(ByVal sender As System.Object, ByVal e > > As System.EventArgs) Handles Button3.Click > > File.Copy(TextBox1.Text, TextBox2.Text) > > End Sub > > End Class Thanks for reply, you're right but i want user to be aware of the thing that how much time or bars the copying process will take. It's not useful or needed for small files, but while copying large files such as hundres of MBs, it would be useful. But still i don't hava a complete info about progress bar with that kind of IO operations. I read somewhere System.io.file class doesn't provide how much bytes are written, maybe an API call may be needed which is another big issue for me. Thanks. "kimiraikkonen" <kimiraikkone***@gmail.com> schrieb: If you are using 'My.Computer.FileSystem.CopyFile' you can set an option in > I use system.io.file class to copy files but i have a difficulty about > implementing a basic / XP-like progress bar indicator during copying > process. the parameters to show the progress dialog while the file is being copied. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Hi Herfried,
Thanks for the information, this was new for me. Cor On Nov 27, 11:49 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h***@gmx.at> wrote: > "kimiraikkonen" <kimiraikkone***@gmail.com> schrieb: Hi Herfried,> > > I use system.io.file class to copy files but i have a difficulty about > > implementing a basic / XP-like progress bar indicator during copying > > process. > > If you are using 'My.Computer.FileSystem.CopyFile' you can set an option in > the parameters to show the progress dialog while the file is being copied. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Thanks for the tip, could you define a simple code for my.filesystem.copyfile within "progressbar". It would be very helpful. On Nov 27, 11:49 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h***@gmx.at> wrote: > "kimiraikkonen" <kimiraikkone***@gmail.com> schrieb: Hi Herfried,> > > I use system.io.file class to copy files but i have a difficulty about > > implementing a basic / XP-like progress bar indicator during copying > > process. > > If you are using 'My.Computer.FileSystem.CopyFile' you can set an option in > the parameters to show the progress dialog while the file is being copied. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Thanks for the help. I've done it with setting this parameter which calls Windows's standard progress bar API (.net 2.0). My.Computer.FileSystem.CopyFile(TextBox1.Text, TextBox2.Text, FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing) Thanks.
How to stop disabled text boxes being greyed out
VB2008 changes? Call HTML control in code behind (ASP.net 2.0) Visual Studio 2005: VB fill circle automatic Can I write this program? Setting up Policies to run Exe file from network drive Kill explorer process and disable it restart automatically Problem Using VB.net Class Library DLL in VBScript using foxpro table from VB.net 2005 with oledb [VB2008] How to replace lines in a textfile? |
|||||||||||||||||||||||