Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Directory Backup including Sub Dirs

Posted on 2000-05-11
4
Medium Priority
?
224 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 300 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

Technology Partners: 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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

670 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