I have this code to copy directories:
But it can't really deal with illegal characters, as it errors out and highlights this lineCode:Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String, Optional _ ByVal bQuiet As Boolean = False) As Boolean If Not IO.Directory.Exists(Src) Then Throw New DirectoryNotFoundException("The directory " & Src & " does not exists") End If If IO.Directory.Exists(Dest) AndAlso Not bQuiet Then If MessageBox.Show("directory " & Dest & " already exists." & vbCrLf & _ "If you continue, any files with the same name will be overwritten", _ "Continue?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, _ MessageBoxDefaultButton.Button2) = DialogResult.Cancel Then Exit Function End If 'add Directory Seperator Character (\) for the string concatenation shown later If Dest.Substring(Dest.Length - 1, 1) <> Path.DirectorySeparatorChar Then Dest += Path.DirectorySeparatorChar End If If Not Directory.Exists(Dest) Then Directory.CreateDirectory(Dest) Dim Files As String() Files = Directory.GetFileSystemEntries(Src) Dim element As String For Each element In Files If Directory.Exists(element) Then 'if the current FileSystemEntry is a directory, 'call this function recursively CopyDirectory(element, Dest & Path.GetFileName(element), True) Else 'the current FileSystemEntry is a file so just copy it File.Copy(element, Dest & Path.GetFileName(element), True) End If Next Return True End Function
Can anyone help?Code:File.Copy(element, Dest & Path.GetFileName(element), True)
Br00nage.




Reply With Quote