Hi,
I have a function for copy a folder with a progressbar, but on the big files the program freezes, and the progressbar increases fastly (the progressbar increases according to the file's size). So i think make the copy in several part for the big files.
Is it possible ? If yes, how can i do that ?
Loading
Danatas GerviPosted Nov 5, 2009, 12:42 PM
Strange task, but if you want so…
;)
private void button1_Click(object sender, EventArgs e)
{
FileStream readerStream = new FileStream("c:\\testBig.txt", FileMode.Open, FileAccess.Read);
FileStream writerStream = new FileStream("d:\\testBig.txt", FileMode.OpenOrCreate, FileAccess.Write);
int index = 0;
byte[] buffByte = new byte[100];
do
{
this.Text = index.ToString(); // here you indication
Application.DoEvents();
index += 100;
readerStream.Read(buffByte, 0, buffByte.Length);
writerStream.Write(buffByte, 0, buffByte.Length);
}
while (readerStream.Length > readerStream.Position);
writerStream.Flush();
writerStream.Close();
readerStream.Close();
}
If you want to increase speed – enlarge the size of buffByte.
kevinPosted Nov 12, 2009, 3:09 AM
Sam HobbsPosted Nov 5, 2009, 10:11 AM
http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=69996
If I understand what you are saying, then you can use a separate thread for the copy.