Hi,
I have a Windows VB.Net app in which I need to keep files in one folder in sync with files in another folder. I have pasted the code below. Can anyone tell me why I end up with a folder with all the file names correct, but the length of each file is zero.
Thanks for your help.
Michael
Public Function SyncFiles() As Integer
Dim CopyToPath As String
Dim CopyFromPath As String
Dim CopyToPathFileI nfo As FileInfo
Dim CopyFromPathFil eInfo As FileInfo
Try
CopyAllFiles = False
For i As Integer = 0 To intNumberOfSlot s - 1
CopyFromPath = AdSlotRecords(i ).strPathAndFil enameOfAdClip
CopyFromPathFil eInfo = New FileInfo(CopyFr omPath)
CopyToPath = AdSlotRecords(i ).strPathAndFil enameOfAdClipOn Client
CopyToPathFileI nfo = New FileInfo(CopyTo Path)
If CopyFromPathFil eInfo.Exists Then ' Make sure source exists
If CopyToPathFileI nfo.Exists Then ' If target exists check for latest version
If CopyFromPathFil eInfo.LastWrite Time > CopyToPathFileI nfo.LastWriteTi me Then
CopyFromPathFil eInfo.CopyTo(Co pyToPath, True)
End If
Else
CopyFromPathFil eInfo.CopyTo(Co pyToPath, True)
End If
Else
Return False
End If
Next
Return True
Catch ex As Exception
Return False
End Try
End Function
--
Michael D. Murphy
Senior Software Architect
SCS-TechResources, Inc.
1400 NW 70 Way
Suite HO1
Plantation, FL 33313-5330
md******@scs-techresources.c om
954-452-1047