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 CopyToPathFileInfo As FileInfo
Dim CopyFromPathFileInfo As FileInfo
Try
CopyAllFiles = False
For i As Integer = 0 To intNumberOfSlots - 1
CopyFromPath = AdSlotRecords(i).strPathAndFilenameOfAdClip
CopyFromPathFileInfo = New FileInfo(CopyFromPath)
CopyToPath = AdSlotRecords(i).strPathAndFilenameOfAdClipOnClien t
CopyToPathFileInfo = New FileInfo(CopyToPath)
If CopyFromPathFileInfo.Exists Then ' Make sure source exists
If CopyToPathFileInfo.Exists Then ' If target exists check for latest version
If CopyFromPathFileInfo.LastWriteTime > CopyToPathFileInfo.LastWriteTime Then
CopyFromPathFileInfo.CopyTo(CopyToPath, True)
End If
Else
CopyFromPathFileInfo.CopyTo(CopyToPath, 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.com
954-452-1047