电源外壳:
$file = "text.txt"
Test-Path $file
# True
Get-Location
# C:\Users\Fors1k
[IO.File]::OpenRead($file)
# FileStream
[IO.FileInfo]::new($file)
# Mode LastWriteTime Length Name
# ---- ------------- ------ ----
# -a---- 05.03.2021 18:12 7 text.txt
gc $file
# test123
Run Code Online (Sandbox Code Playgroud)
一切都好。
PowerShell 核心:
$file = "text.txt"
Test-Path $file
# True
Get-Location
# C:\Users\Fors1k
[IO.File]::OpenRead($file)
# Exception calling "OpenRead" with "1" argument(s): "Could not find file 'C:\Windows\system32\text.txt'."
[IO.FileInfo]::new($file)
# Mode LastWriteTime Length Name
# ---- ------------- ------ ----
# larhs 01.01.1601 3:00
gc $file
# test123 …Run Code Online (Sandbox Code Playgroud)