Hi,
Iam trying to copy an executable from Folder A to Folder B.
1. If a back up executable is found in Folder B then delete it. (Example: delete exe1bkp.exe)
2. If an executable without bkp is found then rename it. (Example: "exe1" & "bkp" & ".exe"
3. Copy the new updated executable "exe1.exe" from Folder A to Folder B.
I am using the following code.
When FileCopy runs, the program generates an error. What is wrong with this code? Pl help.VB Code:
Private Sub CopyFolder() Dim i As Integer, j As Integer, strFile As String, FileName As String, fs Dim SourceFile, DestinationFile, srcFname, dstFname, fileContent, SearchContent List3.Clear Set fs = CreateObject("Scripting.FileSystemObject") strFile = Dir("C:\TempCafesoftUpdateFolder\exes\*.exe") While Not Len(strFile) = 0 List3.AddItem strFile For i = 0 To List3.ListCount - 1 If strFile = List3.List(i) Then For j = 0 To List3.ListCount - 1 'Delete the file FileName = App.Path & "\bkp" & strFile If (fs.FileExists(FileName)) Then fs.DeleteFile (FileName) Next DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents Name App.Path & "\" & strFile As App.Path & "\bkp" & strFile srcFname = "C:\TempCafesoftUpdateFolder\exes\" & strFile dstFname = App.Path & "\" & strFile DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents Label4.Visible = True Label4 = "Copying " & strFile & " to " & App.Path & "\exes" DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents: DoEvents FileCopy srcFname, dstFname Label4.Visible = False End If Next strFile = Dir() Wend End sub
Thanks in advance




Reply With Quote