Syncronizing two folders

peoman

Member
Joined
Oct 17, 2008
Messages
5
Programming Experience
Beginner
I'm trying to build a program which will synchronize two folders and i am using Microsoft Sync Framework.
All i want is to upload the files from folder a to folder b, delete the unnecessary files from folder b and replace the modified files.
With the code below, I've managed to upload the files.
How can i "sync with delete"?
I've read that i must use "echo" but i couldn't find anything like that.
Thanks in advance

VB.NET:
Imports Microsoft.Synchronization
Imports Microsoft.Synchronization.Files
Imports System.IO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Dim _sourceDir As String = "c:\temp\a"
            Dim _destDir As String = "c:\temp\b"

            Dim _sourceId As Guid = Guid.NewGuid()
            Dim _destId As Guid = Guid.NewGuid()

            Dim _syncFilter As FileSyncScopeFilter = New FileSyncScopeFilter()
            _syncFilter.AttributeExcludeMask = FileAttributes.Hidden Or FileAttributes.System

            Dim _syncOptions As FileSyncOptions = FileSyncOptions.None

            Using _sourceProvider As FileSyncProvider = New FileSyncProvider(_sourceId, _sourceDir, _syncFilter, _syncOptions)
                Using _destinationProvider As FileSyncProvider = New FileSyncProvider(_destId, _destDir, _syncFilter, _syncOptions)

                    Dim _syncAgent As SyncOrchestrator = New SyncOrchestrator()
                    _syncAgent.LocalProvider = _sourceProvider
                    _syncAgent.RemoteProvider = _destinationProvider
                    _syncAgent.Direction = SyncDirectionOrder.Upload
                    _syncAgent.Synchronize()

                End Using
            End Using

        End If

    End Sub
 
Back
Top