Exception while copying a file to network driive

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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(5% of times) getting an error 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 me troubleshooting this unexpected and
non understandable exception.

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
.



Relevant Pages

  • exception while copying a file to a network drive
    ... I using the routine below to copy file to a network drive for a regular ... Private Sub CopyFile(ByVal DstBasePath As String, ... Dim strDstFile As String = DstBasePath & ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Exception while copying a file to network driive
    ... devoted exclusively to .net programming on the microsoft news server, ... Private Sub CopyFile(ByVal DstBasePath As String, ... Dim strDstFile As String = DstBasePath & ...
    (microsoft.public.vb.bugs)
  • Re: Read text file to Temp file and apply formating and color chan
    ... I call this routine from the OpenFileDialog; ... public static string LayoutInput ... int txPos; ... int charactersTillPoint; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Programmatically update forms in design view
    ... The routine that I am running is done before the creation of an MDE. ... I have a problem with updating a label on multiple forms. ... Dim Erm As String, fm As String, MyDB As Database, rs As Recordset, e As ...
    (microsoft.public.access.forms)
  • Re: File not found
    ... I think this routine can be modified but I am hung up on the portion of the routine where is tries to open the sLocal file. ... ByVal szFileName As String, _ ... Dim hfile As Long ... If DownloadFile(sSourceUrl, sLocalFile) Then ...
    (microsoft.public.vb.general.discussion)