Click here to Skip to main content
15,912,897 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to add items to the beginning of an array Pin
Chinners11-Jul-08 4:29
Chinners11-Jul-08 4:29 
GeneralRe: How to add items to the beginning of an array Pin
Dave Kreskowiak11-Jul-08 8:09
mveDave Kreskowiak11-Jul-08 8:09 
GeneralRe: How to add items to the beginning of an array Pin
Chinners11-Jul-08 8:33
Chinners11-Jul-08 8:33 
GeneralRe: How to add items to the beginning of an array Pin
Dave Kreskowiak11-Jul-08 9:00
mveDave Kreskowiak11-Jul-08 9:00 
AnswerInstallation Error: Application validation Dose not succeed. Unable To continue + Reference in the manifest does not match the identity of the downloaded assembly Pin
nishkarsh_k10-Jul-08 6:48
nishkarsh_k10-Jul-08 6:48 
GeneralRe: Installation Error: Application validation Dose not succeed. Unable To continue + Reference in the manifest does not match the identity of the downloaded assembly Pin
John_Adams10-Jul-08 19:38
John_Adams10-Jul-08 19:38 
GeneralRe: Installation Error: Application validation Dose not succeed. Unable To continue + Reference in the manifest does not match the identity of the downloaded assembly Pin
nishkarsh_k10-Jul-08 23:58
nishkarsh_k10-Jul-08 23:58 
QuestionCopying Files and it's containing files to another location Pin
CornElvis10-Jul-08 2:38
CornElvis10-Jul-08 2:38 
Hi,

I'm pretty new to the forum and to VB.Net 2008
I use the express version at the moment and try to copy over files and folders from a userprofile within windows XP.
How do I skip the hidden files and folders and/or files that are in use?
I get an exeption everytime it finds something I don't have permission to.
Any idea's?

here is my code so far:
Imports System.IO
Public Class frmProfileCopier
    Dim SourcePath As String, DestPath As String, ExactPath As String


    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)
        End

    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
        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
                '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

    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

I get an exeption on the line with :
File.Copy(element, Dest & Path.GetFileName(element), True)
Also my label1 doesn't work when I use ExactPath instead of the "UserData\" & tbUserName.Text & "\"

Greetzzz,

CornElvis
www.jackied.nl

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 
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 

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.