I’m writing a function like this:
Private Function mostRecent(ByVal folder As Directory) As Date
'function to convert the given directory param as a path obj
Dim foldPathStr = Path.GetFullPath(foldPath)
Dim createDate As Date = Directory.GetCreationTime(foldPathStr)
Dim writeDate As Date = Directory.GetLastWriteTime(foldPathStr)
Dim readDate As Date = Directory.GetLastAccessTime(foldPathStr)
If createDate > writeDate And createDate > readDate Then
Return createDate
ElseIf writeDate > createDate And writeDate > readDate Then
Return writeDate
ElseIf readDate > createDate And readDate > writeDate Then
Return readDate
End If
End Function
I’d like to fill in that commented line with a built-in command, if available. If not, guess I’ll change the parameter.
Pathis a static class – it’s never instantiated; there’s never an instance of aPathobject.That’s assuming we’re talking about the same
Pathclass here… I’m somewhat surprised to seeDirectoryas a parameter type, given that that’s a static class too. Are you sure you don’t meanDirectoryInfo? Or is this a VB class which has been given the same name as aSystem.IOclass just to confuse unwary C# developers?If it is
DirectoryInfo, I think you just want theFullNameproperty.