473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 4234
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Eno | last post by:
I have a problem where I'm developing some code that moves files from one place to another (on the same drive) with the destination file having a new name. What's happening is that the line of...
2
by: Jim | last post by:
I work in the environmental industry and we have large gcms instruments that aquire raw data to an attached computer. These computers are networked, and have shared folders so the data can be...
8
by: luis molina Micasoft | last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make 40 threads of file.copy , 40 copys of files at same time the system is going down and stop responding, this is when i'm...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
10
by: David | last post by:
I have googled to no avail on getting specifically what I'm looking for. I have found plenty of full blown apps that implement some type of file transfer but what I'm specifcally looking for is an...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
10
by: Redhairs | last post by:
In a web farm environment, how to store the user uploading files for future access? Store them in db, local file system or centralized file server? If trying to storing the file in local file...
5
by: CSharper | last post by:
I have a data file which is 2.1GB (zipped), when the exe runs, it copies the content of the zip file to a destination folder. What is the best way to achive this? Current implementation is to zip...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.