Error: does not contain a method named op_addition
Error: does not contain a method named op_addition
我正在尝试使用以下脚本删除每个人的 Chrome 缓存目录,但它总是因为这个毫无意义的荒谬错误而失败。
method invocation failed because system.io.directoryinfo does not contain a method named op_addition
即使我只是将 $loc 写入控制台 window,我也会收到错误消息。我在这里做错了什么?
$path = Get-ChildItem C:\Users\*\ | ?{ $_.PSIsContainer }
ForEach ($folder in $path) {
$loc = $folder + "\AppData\Local\Google\Chrome\User Data\Default\Cache"
# Remove-Item $loc
Write-Host $loc
}
因为您要做的是连接 2 个字符串,但 $folder
不是字符串。这是一个 system.io.directoryinfo
对象,改为执行以下操作:
$loc = $folder.FullName + "\AppData\Local\Google\Chrome\User Data\Default\Cache"
$Folder.Fullname returns 一个可以连接的字符串。
我正在尝试使用以下脚本删除每个人的 Chrome 缓存目录,但它总是因为这个毫无意义的荒谬错误而失败。
method invocation failed because system.io.directoryinfo does not contain a method named op_addition
即使我只是将 $loc 写入控制台 window,我也会收到错误消息。我在这里做错了什么?
$path = Get-ChildItem C:\Users\*\ | ?{ $_.PSIsContainer }
ForEach ($folder in $path) {
$loc = $folder + "\AppData\Local\Google\Chrome\User Data\Default\Cache"
# Remove-Item $loc
Write-Host $loc
}
因为您要做的是连接 2 个字符串,但 $folder
不是字符串。这是一个 system.io.directoryinfo
对象,改为执行以下操作:
$loc = $folder.FullName + "\AppData\Local\Google\Chrome\User Data\Default\Cache"
$Folder.Fullname returns 一个可以连接的字符串。