Sungguk Lim
Sungguk Lim

Reputation: 6228

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

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.

Upvotes: 0

Views: 135

Answers (2)

Security Hound
Security Hound

Reputation: 2548

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.

Upvotes: 0

Alex K.
Alex K.

Reputation: 175916

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).

Upvotes: 4

Related Questions