Solved

Directory Backup including Sub Dirs

Posted on 2000-05-11
4
219 Views
Last Modified: 2013-11-18
Before anyone points me at the samples on htttp://www.mvps.org, I've been there and the samples don't include sub directories.
What I need is an example of backing up files and directories, including subs.
I have the code for checking if files are different.

Thanks
Paul


0
Comment
Question by:PHalse
4 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 100 total points
ID: 2800722
Here's an iterative copy command

                  Private Function MCopy(sSource As String, sDest As String)

                    Dim sFile As String
                    Dim sDirs() As String
                    Dim c As Long
                    Dim d As Long
                    Dim sDest2, N As Long
                   
                   
                    ReDim sDirs(10)
                    N = 10
                   
                    sDest2 = Left(sDest, Len(sDest) - 1)
                   

                   

                    If Dir(sDest2, vbDirectory) = "" Then
                        MkDir (sDest2)
                    End If

                    sFile = Dir(sSource, vbNormal)

                    Do While sFile <> ""
                        FileCopy sSource & sFile, sDest & sFile
                        sFile = Dir
                        'CurrentFile.Caption = "Copying to " & sDest & sFile & "..."
                        'CurrentFile.Refresh
                    Loop

                    sFile = Dir(sSource, vbDirectory)
                    Do While sFile <> ""
                   
                        If c > N Then
                            N = N + 10
                            ReDim Preserve sDirs(N)
                        End If
                       
                        sDirs(c) = sFile
                        sFile = Dir
                        c = c + 1
                    Loop
                   
                    For d = 0 To c - 1
                    ' Ignore the current directory and the encompassing directory.
                        If sDirs(d) <> "." And sDirs(d) <> ".." Then
                            ' Use bitwise comparison to make sure MyName is a directory.
                            If (GetAttr(sSource & sDirs(d)) And vbDirectory) = vbDirectory Then
                                Call MCopy(sSource & sDirs(d) & "\", sDest & sDirs(d) & "\")
                            End If  ' it represents a directory.
                        End If
                    Next
                   
End Function
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2800749
Deighton Writes: "Here's an iterative copy command"

Psssssst.. the word is recursive NOT iterative.. <now shining apple to hand to his English teacher>.. LOL

Very nice example Deighton.. <smile>.

                 
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2800807
A complete backup application that runs in the system tray, you can: - select files or entire folders (including subdirs) to backup; - select the source drives (local or network); - specify the target directory (local or network); - specify an interval in which the backup occurs or a unique time in the day; - specify the days of the week; - select full or incremental backup. It optionally generates a log with all files backed up.


http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=3690
0
 
LVL 1

Author Comment

by:PHalse
ID: 2808113
Thanks Deighton
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to count occurrences of each item in an array.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now