简体   繁体   中英

Semaphore timeout period has expired

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
        {

        }

This tends to be a generic error message and is probably related to three possibilities:

  1. Connection related. Check your network cables, USB Connections / cables, reset the usb hub, network switches..etc.

  2. Check for file names that are too long, or paths that are too long.

  3. Hard drive related. Check you have enough free space and that the drive has no errors and is not fragmented.

EDIT: Added hard drive.

Take a look at these MS Instruction on a similar Error , It seems to be known Issue whencoping files over network

steps for troubleshoot:

  1. Update the driver of wireless network adapters in both of your computers.

  2. Temporarily disable all the firewalls and anti-virus applications, then check the issue again.

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

  1. 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:

  1. Whether this problem occurs in wired network?

  2. If strengthening the network signals, the problem can be changed?

  3. What size of files will lead to this error.

  4. Does this error terminate the copy process?

  5. Models of the wireless network adapter and wireless router.

当我通过USB连接的Drobo驱动器阵列中的硬盘驱动器出现故障时,会发生这种情况

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM