前のトピック: SetFileAttributes - ファイル属性の設定次のトピック: ファイル バージョンの読み取りと比較


SetFileTime - ファイルまたはディレクトリのタイムスタンプ設定

NetWare、Symbian OS、UNIX、Windows、および Windows CE で有効です。

SetFileTime 関数では、ファイルまたはディレクトリのタイムスタンプが設定されます。

関数の形式

SetFileTime(fileName as string, dateAndTime as DateTime, Type as integer) as Boolean
SetFileTime(fileName as string, dateAndTime as DateTime) as Boolean
fileName

日時を変更するファイルの名前を指定します。

dateAndTime

新しく設定する日時を指定します。

タイプ

値 0: 作成日時が変更されます(デフォルト)。

値 1: ファイルへの最終アクセス日時が変更されます。

値 2: ファイルが最後に変更された日時が変更されます。

値 3: 作成日時、最終アクセス日時、および最終書き込み日時が変更されます。

この関数が正常に完了すると、TRUE が返されます。それ以外の場合は、FALSE が返されます。

例:

Rem modify write time
Dim newTime as DateTime
newTime.year = 1999
newTime.month = 12
newTime.day = 31
newTime.hour = 23
newTime.minute = 59
newTime.second = 59
If Not(SetFileTime("c:\autoexec.bat",newTime,2)) Then
	Print ("SetFileTime failed")
	Exit
End If