FileSystemWatcher事件不是从Mac用户触发的

时间:2018-02-28 00:18:18

标签: macos powershell filesystemwatcher

以下脚本在监视共享文件夹的Windows 7 SP1 PC上运行。 Mac用户,运行相当新的iMacs / MacbookPros将文件复制到共享。

$fsw = New-Object System.IO.FileSystemWatcher -Property @{
    Path = "c:\temp"
    IncludeSubdirectories = $false 
}

$event = Register-ObjectEvent -InputObject $fsw –EventName Created -SourceIdentifier fsw -Action {
    if ((Test-Path -Path $EventArgs.FullPath -PathType leaf) -And ($EventArgs.Name -Like "*.jpg")) {

        $imageSource = $EventArgs.FullPath
        Write-Host "Processing File:" $imageSource
    }
}

当Mac用户复制单个文件时,会触发该事件。如果复制了多个文件,则根本不会触发事件,或者只发生一个事件。

有什么想法吗?从Windows计算机将文件复制到共享时我没有问题。

0 个答案:

没有答案