如何解决映射的驱动器断开连接? [英] How to resolve the mapped drive getting disconnected?
问题描述
我正在映射网络驱动器O.我们正面临着驱动器频繁断开的问题。来自CB的文件被复制/移动到此映射驱动器。每当驱动器断开连接时文件移动卡住。仅在重新启动服务器挂起文件时才会移动。
文件的目标路径=O:\ Incoming\其中O是映射驱动器。
下面是文件复制/移动代码
I am having mapped network drive O. We are facing issue of the drive getting disconnected frequently.The files from CB are copied/moved to this mapped drive. whenever drive disconnects file movement gets stuck. Only on restarting the server pending files moves.
Destination Path of file= "O:\Incoming\" where O is the mapped drive.
Below is the file copying/moving code
Error = "Trying for copying the file [" + dr["swift_FileName"].ToString() + "] to STP " + Environment.NewLine;
WriteTextFile(ErrorPath + "STPFileMover_" + DateTime.Now.ToString("ddMMyyyy") + ".txt", DateTime.Now.ToString() + Environment.NewLine + Error);
File.Copy(SourcePath + dr["swift_FileName"].ToString(), DestinationPath + dr["swift_FileName"].ToString());
File.Move(SourcePath + dr["swift_FileName"].ToString(), SourcePath + "\\OLD\\" + dr["swift_FileName"].ToString());
我尝试过:
错误=试图复制文件[+ dr [swift_FileName]。 ToString()+]到STP+ Environment.NewLine;
WriteTextFile(ErrorPath +STPFileMover_+ DateTime.Now.ToString(ddMMyyyy)+。txt,DateTime.Now。 ToString()+ Environment.NewLine + Error);
File.Copy(SourcePath + dr [swift_FileName]。ToString(),DestinationPath + dr [swift_FileName]。ToString());
File.Move(SourcePath + dr [swift_FileName]。ToString(),Sour cePath +\\OLD\\+ dr [swift_FileName]。ToString());
What I have tried:
Error = "Trying for copying the file [" + dr["swift_FileName"].ToString() + "] to STP " + Environment.NewLine;
WriteTextFile(ErrorPath + "STPFileMover_" + DateTime.Now.ToString("ddMMyyyy") + ".txt", DateTime.Now.ToString() + Environment.NewLine + Error);
File.Copy(SourcePath + dr["swift_FileName"].ToString(), DestinationPath + dr["swift_FileName"].ToString());
File.Move(SourcePath + dr["swift_FileName"].ToString(), SourcePath + "\\OLD\\" + dr["swift_FileName"].ToString());
推荐答案
我认为你的问题更紧密与网络/连接问题相关 - 如果你无法解决这些问题,你的下一个最好的选择可能是
a)检查驱动器是否在复制前映射和/或
b)使用http://www.codeguru.com/csharp/csharp/cs_network/windowsservices/article.php/c12357/C-Map-Network-Drive- API.htm用于映射驱动器,然后在复制后取消映射
I think your issue is more closely related to network/connectivity issues - if you cant resolve those issues, your next best bet may be to
a) check wether the drive is mapped before the copy and/or
b) use http://www.codeguru.com/csharp/csharp/cs_network/windowsservices/article.php/c12357/C-Map-Network-Drive-API.htm to map the drive then unmap it after the copy
这篇关于如何解决映射的驱动器断开连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!