I need the most recent folder on a drive (1 Viewer)

jl39775

Registered User.
Local time
Today, 00:07
Joined
Dec 12, 2001
Messages
43
I have a drive that have the following folders.

Jan02
Feb02
.
.
.
Aug02

A new folder is created manually each month i.e. in October I will create a Sep02 folder. What I need to do is grab the folder name of the last folder created. I know how to use the dir$ command but I don't know how I can tell if the folder name is the most recent one created. Does anyone have any ideas how I can do this?

Thanks,

James
 

Tim K.

Registered User.
Local time
Today, 00:07
Joined
Aug 1, 2002
Messages
242
Try the code below.

Private Function FolderCreatedDate()

Dim objFS As Object, objFolder As Object
Dim strFolderPath As String

strFolderPath = "i:\test\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Debug.Print "Created --> " & objFolder.DateCreated
Set objFolder = Nothing
Set objFS = Nothing


End Function
 

Users who are viewing this thread

Top Bottom