Güncel C# ProgressBar ile Dosya Boyutu Okuma

  • Konuyu Başlatan Konuyu Başlatan Falcon
  • Başlangıç tarihi Başlangıç tarihi

Falcon

Yönetici
Kod:
FileInfo fi = new FileInfo(path);
progressBar1.Maximum = 100;

long total = fi.Length;
long read = 0;

using FileStream fs = File.OpenRead(path);
{
    byte[] buffer = new byte[4096];
    int bytes;

    while ((bytes = fs.Read(buffer, 0, buffer.Length)) > 0)
    {
        read += bytes;
        progressBar1.Value = (int)(read * 100 / total);
        Application.DoEvents();
    }
}
 
Geri
Üst