Click here to Skip to main content
15,900,258 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionCopying Files and it's containing files to another location Pin
CornElvis10-Jul-08 2:38
CornElvis10-Jul-08 2:38 
AnswerRe: Copying Files and it's containing files to another location Pin
jzonthemtn10-Jul-08 3:15
jzonthemtn10-Jul-08 3:15 
GeneralRe: Copying Files and it's containing files to another location [modified] Pin
CornElvis10-Jul-08 3:33
CornElvis10-Jul-08 3:33 
GeneralRe: Copying Files and it's containing files to another location Pin
jzonthemtn10-Jul-08 5:13
jzonthemtn10-Jul-08 5:13 
GeneralRe: Copying Files and it's containing files to another location Pin
CornElvis10-Jul-08 5:42
CornElvis10-Jul-08 5:42 
GeneralRe: Copying Files and it's containing files to another location Pin
jzonthemtn10-Jul-08 6:44
jzonthemtn10-Jul-08 6:44 
GeneralRe: Copying Files and it's containing files to another location Pin
Luc Pattyn10-Jul-08 7:10
sitebuilderLuc Pattyn10-Jul-08 7:10 
GeneralRe: Copying Files and it's containing files to another location Pin
CornElvis11-Jul-08 2:40
CornElvis11-Jul-08 2:40 
OK fixed, thanks for the help.
It's now writing the not copied files to a log file and caries on with the process.
here is my code at the moment:
Imports System.IO
Imports System.Security.Permissions




Public Class frmProfileCopier
    Dim SourcePath As String, DestPath As String, ExactPath As String
    Dim attributeReader As System.IO.FileAttributes
    Dim infoReader As System.IO.FileInfo


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        SourcePath = "C:\Documents and Settings\" & tbUserName.Text & "\"
        ExactPath = "UserData\" & tbUserName.Text & "\"
        DestPath = fbdDestDrive.SelectedPath & "\" & ExactPath
        CopyDirectory(SourcePath, DestPath)
        MessageBox.Show("copy done. Please see the exclusions.log for files that couldn't be copied", "Profile Copier")

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        End
    End Sub
    Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String, Optional _
  ByVal bQuiet As Boolean = False) As Boolean
        Try

        
            If Not Directory.Exists(Src) Then
                Throw New DirectoryNotFoundException("The directory " & Src & " does not exists")
            End If
            If 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

                    File.Copy(element, Dest & Path.GetFileName(element), True)
                End If


            Next
        Catch ex As Exception
            Dim writer As New StreamWriter(Label1.Text & "exclusions.log", True, System.Text.Encoding.ASCII)
            writer.WriteLine(ex.Message)
            writer.Close()

        End Try

        Return True


    End Function



    Private Sub btnDestDrive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDestDrive.Click
        fbdDestDrive.ShowDialog()
        Label1.Text = fbdDestDrive.SelectedPath & "UserData\" & tbUserName.Text & "\"
    End Sub


End Class


thanks again!

Greetzzz,

CornElvis
www.jackied.nl

Questionhow to draw a road map in vb 2008? Pin
dunkin_ina9-Jul-08 22:06
dunkin_ina9-Jul-08 22:06 
AnswerRe: how to draw a road map in vb 2008? Pin
jzonthemtn10-Jul-08 4:17
jzonthemtn10-Jul-08 4:17 
GeneralRe: how to draw a road map in vb 2008? Pin
dunkin_ina13-Jul-08 22:07
dunkin_ina13-Jul-08 22:07 
QuestionCannot open external file with space character in filename or path. Pin
Roullakis9-Jul-08 20:48
Roullakis9-Jul-08 20:48 
AnswerRe: Cannot open external file with space character in filename or path. Pin
Ashfield9-Jul-08 21:31
Ashfield9-Jul-08 21:31 
GeneralRe: Cannot open external file with space character in filename or path. Pin
Roullakis9-Jul-08 22:00
Roullakis9-Jul-08 22:00 
GeneralRe: Cannot open external file with space character in filename or path. Pin
Guffa10-Jul-08 0:38
Guffa10-Jul-08 0:38 
GeneralRe: Cannot open external file with space character in filename or path. Pin
Ashfield10-Jul-08 1:20
Ashfield10-Jul-08 1:20 
GeneralRe: Cannot open external file with space character in filename or path. Pin
Guffa10-Jul-08 4:01
Guffa10-Jul-08 4:01 
AnswerRe: Cannot open external file with space character in filename or path. Pin
Ajay.k_Singh9-Jul-08 21:35
Ajay.k_Singh9-Jul-08 21:35 
GeneralRe: Cannot open external file with space character in filename or path. Pin
Roullakis9-Jul-08 21:57
Roullakis9-Jul-08 21:57 
QuestionCHM model program using VB.Net[2005] Pin
kvwarun9-Jul-08 19:53
kvwarun9-Jul-08 19:53 
QuestionError while showing report Pin
Amit Battan Ror9-Jul-08 4:02
Amit Battan Ror9-Jul-08 4:02 
AnswerRe: Error while showing report Pin
Christian Graus9-Jul-08 4:13
protectorChristian Graus9-Jul-08 4:13 
AnswerRe: Error while showing report Pin
Paul Conrad9-Jul-08 13:26
professionalPaul Conrad9-Jul-08 13:26 
AnswerRe: Error while showing report Pin
Rupesh Kumar Swami9-Jul-08 20:12
Rupesh Kumar Swami9-Jul-08 20:12 
GeneralRe: Error while showing report Pin
Amit Battan Ror9-Jul-08 20:29
Amit Battan Ror9-Jul-08 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.