0

How can I know the bytes current being copied during copying large file in .net?

I used to File.Copy method for copying file.

The problem is I can't know the current state during copying file.

Is there anyway that I can check how much the file is being copied? or get a return value?

If not, do I have to make my own method with Filestream or something?

Sorry about my poor English & thanks in advance.

Sungguk Lim
  • 6,109
  • 7
  • 43
  • 63

2 Answers2

4

I would leave copying to the OS rather than rolling out your own, you can use the CopyFileEx API which implements a progress callback (pinvoke).

Alex K.
  • 171,639
  • 30
  • 264
  • 288
0

The problem is I can't know the current state during copying file.

Just use the following method: http://msdn.microsoft.com/en-us/library/windows/desktop/aa364957(v=vs.85).aspx

Is there anyway that I can check how much the file is being copied? or get a return value?

Check the size on the file being created in the new location using a similar method as above.

If not, do I have to make my own method with Filestream or something?

You really should avoid doing something that operating system does.

Security Hound
  • 2,577
  • 3
  • 25
  • 42