Solved

Directory Backup including Sub Dirs

Posted on 2000-05-11
4
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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