Link to home
Start Free TrialLog in
Avatar of Erwin Pombett
Erwin PombettFlag for Switzerland

asked on

with powershell : how can i create a file with a creationtime older that today ?

Hello,

i'd like to generate lots of files with creationtime that i decide.

#the following line is generating my files : OK
$file = New-Object System.IO.FileStream $RootFolder\$fileName, Create, ReadWrite

Open in new window

# i change the size  : OK
$file.SetLength(1MB)

Open in new window

# i create a datetime : OK
$dateTime = [System.DateTime]::Parse("30-11-1973")

Open in new window


# this is not changing my datetime...how should i do ?  : KO
[System.IO.Directory]::SetCreationTime($file, $dateTime)

Open in new window

#error
ERROR: $[System.IO.Directory]::SetCreationTime : The term '$[System.IO.Directory]::SetCreationTime' is not recognized as the name of a cmdlet, function, script file,

# then i close the $file
$file.Close()

Open in new window


how am i supposed to do this ?

thank you in advance for your tips and help.

toshi
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Erwin Pombett

ASKER

thanks for your answer...i'm going to try .

toshi
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial