I have a 2 txt files named mat.txt.
The first on a server dir and the second on c:\mydir
i need to check if the txt on server dir is newest based the txt on c:\mydir if condition is true owervrite the txt on c:\mydir, ....
possible?
CHECK date last modified txt file
-
- Administrator
- Posts: 78493
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: CHECK date last modified txt file
Try this. You have to substitute the correct paths and filenames, of course.
Code: Select all
Sub CheckDate()
Dim strLocal As String
Dim strServer As String
strLocal = "C:\MyDir\Mat.txt"
strServer = "\\MyServer\MyShare\MyFolder\Mat.txt"
If FileDateTime(strServer) > FileDateTime(strLocal) Then
FileCopy strServer, strLocal
End If
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: CHECK date last modified txt file
i cant test now... but sure the code work fineHansV wrote:Try this. You have to substitute the correct paths and filenames, of course.
Code: Select all
Sub CheckDate() Dim strLocal As String Dim strServer As String strLocal = "C:\MyDir\Mat.txt" strServer = "\\MyServer\MyShare\MyFolder\Mat.txt" If FileDateTime(strServer) > FileDateTime(strLocal) Then FileCopy strServer, strLocal End If End Sub