Right i am trying to access a network path. which i know exist. I have tested my code locally and it works but when i go to put it onto the server that is where the problem lies. The code that i am using is as follows if someone sees anything
Code:
'convert our source path into a physical path
Dim sourcePath As String = "\\server\work\" & mJob.Insert(2, "-") & "\LvTest\notapproved"
'get our destination path as physical
Dim destPath As String = "\\server\work\" & mJob.Insert(2, "-") & "\LvLsr"
Try
CopyDirectory(sourcePath, sourcePath + "\Archive", True, True)
CopyDirectory(sourcePath, destPath, True, False)
Catch exc As System.Exception
'do nothing
End Try
Code:
Private Sub CopyDirectory(ByVal sourcePath As String, ByVal destPath As String, ByVal overwrite As Boolean, ByVal archive As Boolean)
Dim sourceDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(sourcePath)
Dim destDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(destPath)
'the source directory must exist for our code to run
If (sourceDir.Exists) Then
'if the destination folder does not exist, create it
If Not (destDir.Exists) Then
destDir.Create()
End If
'loop through all the files of the current directory
'and copy them if overwrite=true or they do not exist
Dim file As System.IO.FileInfo
For Each file In sourceDir.GetFiles()
If (overwrite) Then
file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), True)
If (archive = False) Then
file.Delete()
End If
Else
If ((System.IO.File.Exists(System.IO.Path.Combine(destDir.FullName, file.Name))) = False) Then
file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), False)
If (archive = False) Then
file.Delete()
End If
End If
End If
Next
'loop through all the subfolders and call this method recursively
'Dim dir As System.IO.DirectoryInfo
'For Each dir In sourceDir.GetDirectories()
' If (dir.FullName <> Server.MapPath(tbxDestinationDir.Text)) Then
' CopyDirectory(dir.FullName, System.IO.Path.Combine(destDir.FullName, dir.Name), overwrite)
' End If
'Next
'lblStatusMessage.Text = "Folder copied successfully"
'lblStatusMessage.Visible = True
'if source directory does not exist
End If
End Sub
Also i have tested to make sure the path is right from the server