CHECK date last modified txt file

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

CHECK date last modified txt file

Post by sal21 »

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?

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CHECK date last modified txt file

Post by HansV »

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

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: CHECK date last modified txt file

Post by sal21 »

HansV 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
i cant test now... but sure the code work fine :thankyou: :grin: