총 파일 용량 구해서
파일이 복사되는 동안 총 용량을 기준으로 프로그레스바가 동작하게 하는건데요
다음 폴더 혹은 하위폴더를 복사할 때마다 프로그레스바가 재시작 되네요
While 문이 문제 인 것 같기도 한데.. 혹시 이것만 보고 지적해주실 수 있는분 계신가요
// 총 파일 용량
foreach (FileInfo i in arrfileInfo)
{
if ((i.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
total += i.Length;
}
rs = new FileStream(i.FullName, FileMode.Open); // 네트웤 드라이브에 있는 파일
ws = new FileStream(destPath + "//"
+ i.FullName.Substring(sourcePath.Length, i.FullName.Length - (i.FullName.Substring(0, sourcePath.Length).Length)), FileMode.Create);
// 로컬 드라이브
이 부분이 프로그레스바 표시해주는 부분
while ((readSize = rs.Read(buffer, 0, buffer.Length)) != 0)
{
total_current += readSize;
// ProgressBar
int percent = (int)(((double)total_current * 100) / (double)total);
this.Invoke((SetProgDelegate)delegate(int value)
{
this.pbTransfer.Value = value;
this.lblPer.Text = String.Format("{0}%", value);
}, new object[] { percent });
ws.Write(buffer, 0, readSize);
}