Notifications
Clear all
[Closed] How to use dotnet SetCreationTime?
Jan 25, 2016 9:48 am
Hi,I want to change a file creation time to curret time,but threw error,below is the code:
File=dotNetClass "System.IO.File"
use_file="c:\\Test.txt"
new_time=localtime
File.SetCreationTime use_file new_time
– Runtime error: No method found which matched argument list
2 Replies
Jan 25, 2016 9:48 am
The second argument of SetCreationTime() is of the type <DateTime>, not string, so you have to create a DateTime object first to pass it to the method.
If you wanted to set it to the current time you could use something like:
(
fileName = @"C: est.txt"
dateTime = (dotnetclass "System.DateTime").Now -- Current time
file = dotnetclass "System.IO.File"
file.SetCreationTime fileName dateTime
)
You can also set it to a different Date-Time with something like:
(
fileName = @"C: est.txt"
year = 2013
month = 2
day = 1
hour = 15
minute = 23
second = 12
dateTime = dotnetobject "System.DateTime" year month day hour minute second
file = dotnetclass "System.IO.File"
file.SetCreationTime fileName dateTime
)
Additionally you may also want to consider looking at SetLastAccessTime() and SetLastWriteTime(). Just in case.
1 Reply