关于怎么获取文件修改日期的方法
答案:1 悬赏:20 手机版
解决时间 2021-01-22 21:54
- 提问者网友:一抹荒凉废墟
- 2021-01-22 15:43
关于怎么获取文件修改日期的方法
最佳答案
- 五星知识达人网友:狂恋
- 2021-01-22 16:50
我在网上找到的一种方法:
string filename= "C:\powerbuilder\PbApi\WinApi.txt "
ulong hfile
long rtn
WIN32_FIND_DATA lpFindFileData
SYSTEMTIME lpSystemTime
filetime lpcreate
filetime lpaccess
filetime lpwrite
FILETIME lpFileTime
FindFirstFile(filename,lpFindFileData)
lpFileTime = lpFindFileData.creationtime
rtn = FileTimeToSystemTime(lpFileTime,lpSystemTime)
Messagebox( "creationtime ", string(lpSystemTime.wyear)+ "年 "+string(lpSystemTime.wmonth)+ "月 "+string(lpSystemTime.wday)+ "日 ")
相关结构:
$PBExportHeader$win32_find_data.srs
global type WIN32_FIND_DATA from structure
unsignedlong fileattributes
filetime creationtime
filetime lastaccesstime
filetime lastwritetime
unsignedlong filesizehigh
unsignedlong filesizelow
unsignedlong reserved0
unsignedlong reserved1
character filename[260]
character alternatefilename[14]
end type
$PBExportHeader$filetime.srs
global type FILETIME from structure
ulong dwLowDateTime
ulong dwHighDateTime
end type
$PBExportHeader$systemtime.srs
global type SYSTEMTIME from structure
uint wYear
uint wMonth
uint wDayOfWeek
uint wDay
uint wHour
uint wMinute
uint wSecond
uint wMilliseconds
end type
函数定义
FUNCTION ulong FileTimeToSystemTime(ref FILETIME lpFileTime,ref SYSTEMTIME lpSystemTime) LIBRARY "kernel32.dll "
FUNCTION ulong FindFirstFile(ref string lpFileName,ref WIN32_FIND_DATA lpFindFileData) LIBRARY "kernel32.dll " ALIAS FOR "FindFirstFileA "
但是,运行时总是提示下面几行有问题:
FILETIME lpFileTime
FindFirstFile(filename,lpFindFileData)
lpFileTime = lpFindFileData.creationtime
rtn = FileTimeToSystemTime(lpFileTime,lpSystemTime)
建立一个userobject,命名为n_cst_liveupdate
然后对该对象edit source ,将下面那些内容复制替换掉里面的内容,然后保存
n_cst_liveupdate是一个取(和设置)本地文件最后修改日期的自定义对象
问题出在什么地方,是否还有其它好的办法,请各位多多指教
string filename= "C:\powerbuilder\PbApi\WinApi.txt "
ulong hfile
long rtn
WIN32_FIND_DATA lpFindFileData
SYSTEMTIME lpSystemTime
filetime lpcreate
filetime lpaccess
filetime lpwrite
FILETIME lpFileTime
FindFirstFile(filename,lpFindFileData)
lpFileTime = lpFindFileData.creationtime
rtn = FileTimeToSystemTime(lpFileTime,lpSystemTime)
Messagebox( "creationtime ", string(lpSystemTime.wyear)+ "年 "+string(lpSystemTime.wmonth)+ "月 "+string(lpSystemTime.wday)+ "日 ")
相关结构:
$PBExportHeader$win32_find_data.srs
global type WIN32_FIND_DATA from structure
unsignedlong fileattributes
filetime creationtime
filetime lastaccesstime
filetime lastwritetime
unsignedlong filesizehigh
unsignedlong filesizelow
unsignedlong reserved0
unsignedlong reserved1
character filename[260]
character alternatefilename[14]
end type
$PBExportHeader$filetime.srs
global type FILETIME from structure
ulong dwLowDateTime
ulong dwHighDateTime
end type
$PBExportHeader$systemtime.srs
global type SYSTEMTIME from structure
uint wYear
uint wMonth
uint wDayOfWeek
uint wDay
uint wHour
uint wMinute
uint wSecond
uint wMilliseconds
end type
函数定义
FUNCTION ulong FileTimeToSystemTime(ref FILETIME lpFileTime,ref SYSTEMTIME lpSystemTime) LIBRARY "kernel32.dll "
FUNCTION ulong FindFirstFile(ref string lpFileName,ref WIN32_FIND_DATA lpFindFileData) LIBRARY "kernel32.dll " ALIAS FOR "FindFirstFileA "
但是,运行时总是提示下面几行有问题:
FILETIME lpFileTime
FindFirstFile(filename,lpFindFileData)
lpFileTime = lpFindFileData.creationtime
rtn = FileTimeToSystemTime(lpFileTime,lpSystemTime)
建立一个userobject,命名为n_cst_liveupdate
然后对该对象edit source ,将下面那些内容复制替换掉里面的内容,然后保存
n_cst_liveupdate是一个取(和设置)本地文件最后修改日期的自定义对象
问题出在什么地方,是否还有其它好的办法,请各位多多指教
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯