Copy files to another directory
Posted on 2005-04-18
I'm trying to create a basic application that copies files from one directory to another. The target directory name can change though. It needs to loop through the main directory and sub directories.
I may be going about it wrong, it tells me the directory does not exist, it has an extra "coldfusion" and if i remove it, it tells me the file "c:\test" already exists. What am I doing wrong?
Sub GetDirectories(ByVal Directory As String)
Dim di As New DirectoryInfo(Directory)
For Each fi As FileInfo In di.GetFiles()
'lblStatus.Text = fi.Name
If fi.Extension = ".cfm" Then
File.Copy("C:\Inetpub\wwwroot\ColdFusion" & "\" & di.Name & "\" & fi.Name, "C:\test")
For Each dir As DirectoryInfo In di.GetDirectories()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click