I have a button I use to copy a folder from one location to another.
the code looks like this:
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Const FOLDER_FROM As String = "C:\Testcopy1" ' Folder to copy from
Const FOLDER_TO As String = "C:\Mappestruktur" 'Folder to create above folder in
Dim newDir As DirectoryInfo = Directory.CreateDirectory(FOLDER_TO & "\" & New DirectoryInfo(FOLDER_FROM).Name)
CopyFiles(New DirectoryInfo(FOLDER_FROM), newDir)
End Sub
Private Sub CopyFiles(ByVal FolderFrom As DirectoryInfo, ByVal FolderTo As DirectoryInfo)
Dim Files() As String = Directory.GetFiles(FolderFrom.FullName)
Dim SF() As String = Directory.GetDirectories(FolderFrom.FullName)
Dim Var As Integer
For Var = Files.GetLowerBound(0) To Files.GetUpperBound(0)
File.Copy(Files(Var), FolderTo.FullName & "\" & New FileInfo(Files(Var)).Name)
Next
For Var = SF.GetLowerBound(0) To SF.GetUpperBound(0)
Dim dName As String = New DirectoryInfo(SF(Var)).Name
Dim newD As New DirectoryInfo(FolderTo.FullName & "\" & dName)
newD.Create()
CopyFiles(New DirectoryInfo(FolderFrom.FullName & "\" & dName), newD)
Next
End Sub
Now I have a folder in my project I would like to copy to an optional location.
how do I set the "Folder from" const to a location inside my project and how can I set an optional location to copy the folder to at runtime?