2011-10-04 13 views
0

我正在寫一個函數是這樣的:VB.NET中有一個函數從給定的目錄對象中獲取路徑對象嗎?

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 

我想,以填補在註釋行與內置命令,如果有的話。如果不是,請猜我會改變參數。

回答

2

Path是一個靜態類 - 它從來沒有實例化;有從來沒有一個Path對象的實例。

這是假設我們在這裏談論的是同樣的Path類......我有些驚訝地看到Directory作爲參數類型,因爲那也是一個靜態類。你確定你不是指DirectoryInfo?或者,這是一個VB類,它被賦予與System.IO類相同的名稱,只是爲了混淆不必要的C#開發人員?

如果它DirectoryInfo,我想你只想要FullName屬性。

相關問題