471,354 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

File.Copy problem large number files over network

I am using standard File.Copy(source,dest,true) method in C# and I have
problem with copying large number of files.
Here is my code:
foreach (FileInfo file in files)
{
File.Copy(file.FullName,destPath+ "\\" + file.Name, true);
}

This code copies only 5 or 10 files but in "files" collection there is 60
files.
I copy files over local network.
I think that this code (File.Copy) calls
Win32Native.CopyFile(fullPathInternal, dst, !overwrite))
and after that it runs again if foreach but coping is not finished.
After large number requests is send File.Copy is not finished for all files.
Is there a way to get response after File.Copy operation is finished?
Thanks
Radenko
Jun 27 '08 #1
1 3909
Instead of using File.Copy you could just use something like FileStream. In
that case you would have greater control over the copy process and you could
do it either in synchronous or asynchronous manner. There is a lot of
examples out there how to use FileStream. Hope that helps.

"Radenko_Zec" <Ra********@discussions.microsoft.comwrote in message
news:66**********************************@microsof t.com...
I am using standard File.Copy(source,dest,true) method in C# and I have
problem with copying large number of files.
Here is my code:
foreach (FileInfo file in files)
{
File.Copy(file.FullName,destPath+ "\\" + file.Name, true);
}

This code copies only 5 or 10 files but in "files" collection there is 60
files.
I copy files over local network.
I think that this code (File.Copy) calls
Win32Native.CopyFile(fullPathInternal, dst, !overwrite))
and after that it runs again if foreach but coping is not finished.
After large number requests is send File.Copy is not finished for all
files.
Is there a way to get response after File.Copy operation is finished?
Thanks
Radenko
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Matthew Eno | last post: by
8 posts views Thread by luis molina Micasoft | last post: by
10 posts views Thread by David | last post: by
AdrianH
1 post views Thread by AdrianH | last post: by
10 posts views Thread by Redhairs | last post: by
5 posts views Thread by CSharper | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.