修改檔案時間

2021-04-25 11:28:37 字數 2121 閱讀 4957

handle hfile;

filetime ftcreationtime;

filetime ftlastaccesstime;

filetime ftlastwritetime;

systemtime stcreationtime;

systemtime stlastaccesstime;

systemtime stlastwritetime;

hfile = createfile("c://1.txt",                   //lpctstr lpfilename,

generic_read|generic_write,         //dword dwdesiredaccess,

file_share_read|file_share_delete,

null,                //lpsecurity_attributes lpsecurityattributes,

open_always,

file_flag_backup_semantics,         //dword dwflagsandattributes,

null);

if (hfile == invalid_handle_value)

else

filetimetosystemtime(

&ftcreationtime,

&stcreationtime

); filetimetosystemtime(

&ftlastaccesstime,

&stlastaccesstime

); filetimetosystemtime(

&ftlastwritetime,

&stlastwritetime

); trace("the stcreationtime :%d-%d-%d %d:%d:%d/n",

stcreationtime.wyear,

stcreationtime.wmonth,

stcreationtime.wday,

stcreationtime.whour,

stcreationtime.wminute,

stcreationtime.wsecond);

trace("the stlastaccesstime:%d-%d-%d %d:%d:%d/n",

stlastaccesstime.wyear,

stlastaccesstime.wmonth,

stlastaccesstime.wday,

stlastaccesstime.whour,

stlastaccesstime.wminute,

stlastaccesstime.wsecond);

trace("the stlastwritetime:%d-%d-%d %d:%d:%d/n",

stlastwritetime.wyear,

stlastwritetime.wmonth,

stlastwritetime.wday,

stlastwritetime.whour,

stlastwritetime.wminute,

stlastwritetime.wsecond);

// 設定檔案時間

stcreationtime.wyear--;

stlastaccesstime.wyear--;

stlastwritetime.wyear--;

systemtimetofiletime(

&stcreationtime,

&ftcreationtime

);systemtimetofiletime(

&stlastaccesstime,

&ftlastaccesstime

);systemtimetofiletime(

&stlastwritetime,

&ftlastwritetime

);setfiletime(

hfile,

&ftcreationtime,

&ftlastaccesstime,

&ftlastwritetime

);closehandle(hfile);

修改檔案修改時間的東西

include stdafx.h include windows.h include iostream.h include stdlib.h int main int argc,char argv setfiletime hfile,lpfiletime null,lpfiletime null,f...

php獲取檔案建立時間 修改時間

filemtime string filename 返回檔案上次被修改的時間,出錯時返回 false。時間以 unix 時間戳的方式返回,可用於 date filectime string filename 返回檔案上次 inode 被修改的時間,如果出錯則返回 false。時間以 unix 時間戳...

檔案內容查閱及時間修改

cat abentv a 相當於 vet b 在非空白行列出行號 e 將結尾斷行字元 列印出來 n 在所有行前列出行號 t 將 tab 按鍵以 i 顯示出來 v 列出一些看不出來的字元 cat 順序列出檔案內容 tac倒序列出檔案內容 more 檔名 less 用法與其相似 空格鍵 向下翻一頁 en...