Solved

Directory Backup including Sub Dirs

Posted on 2000-05-11
4
218 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

758 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

12 Experts available now in Live!

Get 1:1 Help Now