0

复制文件时如何在WIN APP中创建暂停和停止和恢复按钮?

MyProject 设计快照:

http://www.uploadtak.com/images/f7636_Snapshot_20121207_14.jpg

代码 MyProject 的快照:

http://www.uploadtak.com/images/y564_Snapshot_20121207_14.jpg

非常感谢

4

1 回答 1

0
            for (int i = 0; i <= inStream.Length; i++)
            {

                worker.ReportProgress(i);

                //System.Threading.Thread.Sleep(100);

                fileStream.SetLength(inStream.Length);
                int bytesRead = -1;
                byte[] bytes = new byte[bufferSize];

                while (puase);

                if (cancel)
                {
                    offsetw = 0; fileStream.Flush();
                    return;

                }
                bytesRead = inStream.Read(bytes, offsetw, bufferSize);

                fileStream.Write(bytes, offsetw, bytesRead);
                offsetw *= 1024;

            }

内部空while循环,暂停操作,可以在Pause Button中切换puase值

于 2012-12-15T06:17:58.277 回答