Get file modified date in VB.NET

后端 未结 2 1752
再見小時候
再見小時候 2021-02-12 11:40

I have a number of files in a folder, and I need to get the last modified date. So I used

FDate = IO.File.GetLastWriteTime(FName)

It works fine

相关标签:
2条回答
  • 2021-02-12 12:36

    From File.GetLastWriteTime Method:

    If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

    The file you are querying is probably missing.

    0 讨论(0)
  • 2021-02-12 12:37

    The query mentioned below will get the correct LastModifiedDate for all of the files contained in a folder.

        Dim strFilepath = ""  'Specify path details
        Dim directory As New System.IO.DirectoryInfo(strFilepath)
        Dim File As System.IO.FileInfo() = directory.GetFiles()
        Dim File1 As System.IO.FileInfo
        For Each File1 In File
            Dim strLastModified As String
            strLastModified = System.IO.File.GetLastWriteTime(strFilepath & "\" & File1.Name).ToShortDateString()
        Next
    
    0 讨论(0)
提交回复
热议问题