Question Latest created subfolder name

Private Function GetNewestSubfolderPath(folderPath As String) As String
    Dim folder As New DirectoryInfo(folderPath)
    Dim subfolders = folder.GetDirectories()
    Dim newestSubfolder = subfolders.OrderByDescending(Function(di) di.CreationTime).FirstOrDefault()

    Return If(newestSubfolder Is Nothing, CStr(Nothing), newestSubfolder.FullName)
End Function
 
Back
Top