我是 PowerShell 的新手。我想在每次更改时向 ArrayList 添加文件路径。但是,此 PowerShell 脚本以某种方式失败。任何提示我可能做错了什么?
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "C:\Mydir"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true
$jobs = New-Object System.Collections.ArrayList
$changed = Register-ObjectEvent $watcher "Changed" -Action {
$changedFile = $($eventArgs.FullPath)
$jobs.Add($changedFile)
}