Solved

Updating local machines on a network

Posted on 1998-07-29
1
182 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now