By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,521 Members | 1,274 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,521 IT Pros & Developers. It's quick & easy.

progressbat control example

P: n/a
Hi,
i want to implement a progress bar control when reading a file.Can any one
tell me how do i do that?
Reny
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Reny,

If its a text file you could count the number of lines on
it. Then You open it and read line by line and increase
the value and the maximum would be the number of lines.

Kind Regards
Jorge
-----Original Message-----
Hi,
i want to implement a progress bar control when reading a file.Can any onetell me how do i do that?
Reny
.

Nov 20 '05 #2

P: n/a
* "Reny J Joseph Thuthikattu" <re**@bxtech.com> scripsit:
i want to implement a progress bar control when reading a file.Can any one
tell me how do i do that?


Sample (untested):

\\\
Dim s As New System.IO.BinaryReader(New System.IO.FileStream("C:\WINDOWS\WIN.INI", IO.FileMode.Open))
Dim t() As Byte ' Buffer.
Me.ProgressBar1.Minimum = 0
Me.ProgressBar1.Maximum = s.BaseStream.Length
Dim BytesRead As Long
Dim WholeFile As New System.Text.StringBuilder
While BytesRead < s.BaseStream.Length
t = s.ReadBytes(32) ' Specify number of bytes to be read here.
WholeFile.Append(System.Text.Encoding.Default.GetS tring(t))
BytesRead = BytesRead + t.Length
Me.ProgressBar1.Value = BytesRead
Threading.Thread.Sleep(100) ' For test purposes.
End While
s.Close()
MsgBox(WholeFile.ToString() & "|")
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.