Solved

Directory Backup including Sub Dirs

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

624 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