I am currently creating a little application which will essentially backup my work I do at college.
It works by me saving all my work onto a flash drive. When I run the application it will copy all the contents of the flash drive and copying to my college directory and when I'm at home copy to my Dropbox folder. This essentially gives me 4+ areas where my work is saved. Unfortunately, the college computers due to network restrictions and other problems, the use Dropbox on the college machines (I obviously can still access the website).
My problem being that there is no option to copy a directory and its contents to another area as the System.IO.Directory does not have a copy command.
I am currently able to copy files but it isn't recursive and I want the folder to be copied too.
Here's what I currently have:
Imports System.IO
Imports System
Public Class Form1
Dim FilePath As String
Dim DestinationPath As String
Private Sub cmdSync_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSync.Click
FilePath = "J:\Test\"
If (Directory.Exists(FilePath)) Then
For Each fName As String In Directory.GetFiles(FilePath)
If File.Exists(fName) Then
Dim dFile As String = String.Empty
dFile = Path.GetFileName(fName)
Dim dFilePath As String = String.Empty
dFilePath = DestinationPath + dFile
File.Copy(fName, dFilePath, True)
End If
Next
End If
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked = True Then
DestinationPath = "W:\"
Else
DestinationPath = ""
End If
Label1.Text = DestinationPath
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked = True Then
DestinationPath = "C:\Dropbox\"
Else
DestinationPath = ""
End If
Label1.Text = DestinationPath
End Sub
End Class
Thank you.

New Topic/Question
Reply



MultiQuote




|