I using the routine below to copy file to a network drive for a regular
backup process. Before calling this routine I using another function to check
the presence of the LAN connection and the server where the network drive
exists.
Although of this check I am sometimes getting an exception (in 5% of
times)saying "Could not find the U:\...\File.ext" or part of its path"
Although the network dirve is available and accessible by windows explorer
and the path is correct and
existing.
I would apreciate if some one can help troubleshooting this unexpected and
non understandable error.
Private Sub CopyFile(ByVal DstBasePath As String, ByVal SrcFileInfo As
FileInfo)
Try
Dim strDstFile As String = DstBasePath &
SrcFileInfo.FullName.Substring(2)
Dim DstFileInfo As New FileInfo(strDstFile)
If DstFileInfo.Directory.Exists = False Then
DstFileInfo.Directory.Create()
End If
Me.c_Status = String.Format("Copying {0}{1}To {2}", SrcFileInfo.Name,
vbCrLf, DstBasePath)
Me.c_Progress += 1
Me.c_FCD_Status.Invoke(SrcFileInfo.Name, Me.c_Progress, Me.c_Status,
True)
If DstFileInfo.Exists = False Then
SrcFileInfo.CopyTo(DstFileInfo.FullName)
ElseIf DstFileInfo.LastWriteTime <> SrcFileInfo.LastWriteTime Then
SrcFileInfo.CopyTo(DstFileInfo.FullName, True)
End If
Catch exIO As IOException
Catch ex As Exception
End Try
End Sub