* "Reny J Joseph Thuthikattu said:
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.GetString(t))
BytesRead = BytesRead + t.Length
Me.ProgressBar1.Value = BytesRead
Threading.Thread.Sleep(100) ' For test purposes.
End While
s.Close()
MsgBox(WholeFile.ToString() & "|")
///