Re: Exception while copying a file to network driive

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




This group is for VB6 and earlier. I recommend you take a look at the groups
devoted exclusively to .net programming on the microsoft news server, named
such as:

news://msnews.microsoft.com/microsoft.public.dotnet.general
news://msnews.microsoft.com/microsoft.public.dotnet.languages.vb
news://msnews.microsoft.com/microsoft.public.vsnet.general
.... etc.

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------



".Net Believer" <NetBeliever@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A2CACA27-990F-4471-BC7E-B5894149F93E@xxxxxxxxxxxxxxxx
: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