Not sure how many of you know apps like Total copy or Tera Copy. These apps allow you to pause the copy process right in the middle of any file.
I would like to know if this could be done in C# and how? This will also help with some error handling when copying through LAN.
I've tried Google, but I'm not finding what I'm looking for.
Thanks
Loading
Jan MontanoPosted Jan 5, 2009, 10:12 PM
something like this:
FileStream fileStream = File.OpenRead(@"C:\test.txt");
BinaryReader binaryReader = new BinaryReader(fileStream);
string searchKey = "test";
FileStream writeStream = File.Create(@"C:\test1");
BinaryWriter binaryWriter = new BinaryWriter(writeStream);
string data;
int currentPosition = 0;
while (currentPosition <= fileStream.Length)
{
data = new string(binaryReader.ReadChars(0x10000));
currentPosition += 0x10000;
binaryWriter.Write(data);
// insert code here to Thread.Sleep(0) when paused and continure as soon as it's unpaused. you could use events for this.
}
binaryReader.Close();
binaryWriter.Close();