⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 如何取得文件名的创建时间、修改时间、大小.txt

📁 VB技巧问答10000例 VB技巧问答10000例
💻 TXT
字号:
使 用 FileDateTime函 数 获 得 最 后 修 改 事 件 。 使 用 FileLen函 数 获 得 文 件 大 小 (字 节 为 单 位 )。 获 得 文 件 建 立 时 间 需 要 借 助 API函 数 , 如 : 
    Function CreateTime(sFilename As String) As Date 
     Dim hFile As Long 
     Dim sDate As String 
     
     ' Open file 
     hFile = CreateFile(sFilename, GENERIC_READ, _ 
     FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) 
     If hFile = -1 Then RaiseError 
     
     GetFileTime hFile, ftCreateTime, ByVal 0&, ByVal 0& 
     
     ' Get Create time. 
     FileTimeToLocalFileTime ftCreateTime, ftCreateTime 
     FileTimeToSystemTime ftCreateTime, stSystemTime 
     sDate = stSystemTime.wYear & "/" _ 
     & stSystemTime.wMonth & "/" & stSystemTime.wDay _ 
     & " " & stSystemTime.wHour & ":" _ 
     & stSystemTime.wMinute & ":" & stSystemTime.wSecond 
     
     ' Close file 
     CloseHandle hFile 
     
     CreateTime = CDate(sDate) 
    End Function 
<END>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -