Tuesday, December 18

How to get latest file in a folder

Hello friends!!

Here is a brief code for getting latest/newest file in a particular folder/directory...

Dim LatestFile
Set oFolder=CreateObject("scripting.FileSystemObject").GetFolder("E:\Dwnld")
For Each eachFile In oFolder.Files
    If LatestFile = "" Then
        Set LatestFile = eachFile
    Else If LatestFile.DateCreated < eachFile.DateCreated Then
            Set LatestFile = eachFile
        End If
    End If

Msgbox LatestFile.Name

1 comment:

  1. In this blog, I will show you how to find the latest file or folder in particular path.visit here Super.An informative one. It is a new information for me. It help me to know about it. Thanks for sharing this information.