473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Copying files with progress bar

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
Nov 27 '07 #1
6 4936
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" <ki*************@gmail.comschreef in bericht
news:5d**********************************@o42g2000 hsc.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
Nov 27 '07 #2
On Nov 27, 8:24 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
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.comschreef in berichtnews:5d**********************************@o 42g2000hsc.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
Hi Cor,
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.
Nov 27 '07 #3
"kimiraikkonen" <ki*************@gmail.comschrieb:
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/>

Nov 27 '07 #4
Hi Herfried,

Thanks for the information, this was new for me.
Cor
Nov 28 '07 #5
On Nov 27, 11:49 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"kimiraikkonen" <kimiraikkone...@gmail.comschrieb:
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/>
Hi Herfried,
Thanks for the tip, could you define a simple code for
my.filesystem.copyfile within "progressbar". It would be very helpful.
Nov 28 '07 #6
On Nov 27, 11:49 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"kimiraikkonen" <kimiraikkone...@gmail.comschrieb:
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/>
Hi Herfried,
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.
Nov 28 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bob Bedford | last post by:
I've a page where the user may enter some values and upload some pictures. Unfortunately, some pictures coming from digital camera are very big, and take a lot of time for uploading. I've...
22
by: Bryan Rickard | last post by:
I wrote a simple program in VB6 to copy all the files from a directory on a CD-ROM to my hard disk. There are about 10 files, each about 30MB. The program uses Get and Put to get data from the...
3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
0
by: Dan | last post by:
We debug a VB.Net App that uses compact framework to a DAP Windows CE.Net device. When I debug I would like to only have the EXE copied down. Right now it copies any referrences as well and...
4
by: carmen | last post by:
Is it possible to show some movement in the screen while copying a file? I tried to use a timer that change the position of an image but when I start the copy of a file from diskette all is stopped...
8
by: Randy | last post by:
Hi, is it possible to show the progress of a big file being copied e.g. in a "progressbar"? I tried to use file.copy - but this seems to make no sense :-( Thanks in advance, Randy
7
by: Wayne Gibson | last post by:
Hi, I need some advise with a java applet. I am nearing completing of the project and am getting a little concerned how long it is taking for the applet to load. I have developed the java applet...
2
by: Edhy Rijo [Progytech] | last post by:
Hi All, I am learning VB.NET and building small application that will do the following: 1.. Copy all files from a DVD to a specific folder in the hard drive and overwrite all files always. The...
0
by: Analizer1 | last post by:
Ive Written a static FileCopy from all your experiences , what would be a good Buffer size Byte array..for best performance.. I know there is a built in file.copy ..I need to put progress bar...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.