Solved

Updating local machines on a network

Posted on 1998-07-29
1
216 Views
Last Modified: 2013-11-13
I,m looking for a simple routine that compares the file dates of a single file on both a server and a local machine and if the date on the server is newer than the local machine will copy the file over, overwriting the old one, Any clues ??? p.s. i am new to V.B.
0
Comment
Question by:cs9ue
1 Comment
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1467039
You could use the Robocopy application wich come with the NT ressource kit and is the same than the "rdist" command under Unix.

Other wise, you have to do as following :

Public Sub Robocopy(sServer As String, sLocal As String)
   ' *** Maintain same files from a Server to a lical drive
   
   Dim sFile         As String

   sFile = Dir(sServer)

   Do While (sFile <> "")
      ' *** Test if the file exists
      If Existfile(sFile) = False Then
         ' *** Does not exists
         FileCopy sServer & "\" & sFile, sLocal & "\" & sFile
         
         GoTo NEXT_FILE
      End If
     
      ' *** The file exists
     
      ' *** Verify the size
      If FileLen(sServer & "\" & sFile) <> FileLen(sLocal & "\" & sFile) Then
         ' *** Not the same size
         FileCopy sServer & "\" & sFile, sLocal & "\" & sFile
         
         GoTo NEXT_FILE
      End If
     
      ' *** Verify the date
      If FileDateTime(sServer & "\" & sFile) <> FileDateTime(sLocal & "\" & sFile) Then
         ' *** Not the same date/time
         FileCopy sServer & "\" & sFile, sLocal & "\" & sFile
         
         GoTo NEXT_FILE
      End If
     
NEXT_FILE:
      sFile = Dir()
   Loop

End Sub

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

840 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