问题
I have a simple C# program that copies files from one network share to another. The program just threw a "The semaphore timeout period has expired" error. I've never seen this before and I'm kind of confused as to what it is.
The code is pretty simple: (srcPath and destPath are read from configuration settings)
DirectoryInfo di = new DirectoryInfo(srcPath);
try
{
FileInfo[] files = di.GetFiles();
foreach (FileInfo fi in files)
{
if(!(fi.Name.Contains("_desc")))
{
File.Copy(fi.FullName, destPath + fi.Name, true);
}
}
}
catch (Exception xx)
{
SendMail(xx.Message, xx.StackTrace);
}
finally
{
}
回答1:
This tends to be a generic error message and is probably related to three possibilities:
Connection related. Check your network cables, USB Connections / cables, reset the usb hub, network switches..etc.
Check for file names that are too long, or paths that are too long.
Hard drive related. Check you have enough free space and that the drive has no errors and is not fragmented.
EDIT: Added hard drive.
回答2:
Take a look at these MS Instruction on a similar Error, It seems to be known Issue whencoping files over network
steps for troubleshoot:
Update the driver of wireless network adapters in both of your computers.
Temporarily disable all the firewalls and anti-virus applications, then check the issue again.
To exclude the factors from other services and applications, do a clean boot to check the issue and perform Step 4.
(KB929135) How to troubleshoot a problem by performing a clean boot in Windows Vista http://support.microsoft.com/default.aspx?scid=kb;EN-US;929135
- With clean boot, try to apply the hotfixes contained in the following KB articles:
(KB932045) Error message when you use a network connection to copy a large file from one Windows Vista-based computer to another Windows Vista-based computer: "The connection has been lost" http://support.microsoft.com/default.aspx?scid=kb;EN-US;932045
(KB932063) Several problems occur on a Windows Vista-based computer when you work in a wireless network environment http://support.microsoft.com/default.aspx?scid=kb;EN-US;932063
If problem still persists after steps above, this issue is very possibly due to network devices or configurations, please let me know:
Whether this problem occurs in wired network?
If strengthening the network signals, the problem can be changed?
What size of files will lead to this error.
Does this error terminate the copy process?
Models of the wireless network adapter and wireless router.
回答3:
This happens to me when a hard drive fails in my Drobo drive array connected over USB
来源:https://stackoverflow.com/questions/12351122/semaphore-timeout-period-has-expired