powershell FileSystemWatcher监控文件变化
来源:互联网 发布:自制nas网络存储服务器 编辑:程序博客网 时间:2024/06/05 08:27
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")$folder = "E:\test" #要监控的文件夹#设置任务栏图标$Icon = "C:\Windows\winsxs\amd64_microsoft-windows-dxp-deviceexperience_31bf3856ad364e35_6.1.7601.17514_none_a54b31331066c8e2\sync.ico"$form = new-object System.Windows.Forms.Form $ni = new-object System.Windows.Forms.NotifyIcon$niMenu = new-object System.Windows.Forms.ContextMenu$watcher = New-Object System.IO.FileSystemWatcher $folder$ni.Icon = New-object System.Drawing.Icon($Icon)$ni.ContextMenu = $niMenu$miExit = new-object System.Windows.Forms.MenuItem$miExit.Text = "Exit" $miExit.Add_Click({Stop-Process -id $pid})$niMenu.MenuItems.AddRange(@($miExit)) $watcher.Filter="*.*"$watcher.InternalBufferSize=65536$watcher.IncludeSubDirectories = $true$watcher.SynchronizingObject = $form $form.ShowInTaskbar = $False $form.WindowState = "minimized"function action{param($message)Write-Host $message $message >> e:\filechange.log} #在这里进行日志操作 $watcher.NotifyFilter = "FileName,DirectoryName,LastWrite"$watcher.add_Changed({$message = "$((get-date).ToShortTimeString()) : $($_.FullPath) $($_.ChangeType)" action $message})$watcher.add_Created({$message = "$((get-date).ToShortTimeString()) : $($_.FullPath) $($_.ChangeType)"action $message})$watcher.add_Deleted({$message = "$((get-date).ToShortTimeString()) : $($_.FullPath) $($_.ChangeType)" action $message})$watcher.add_Renamed({$message = "$((get-date).ToShortTimeString()) : $($_.OldFullPath) to $($_.FullPath) $($_.ChangeType)"action $message})$watcher.EnableRaisingEvents = $true$NI.Visible = $True$form.showdialog()
0 0
- powershell FileSystemWatcher监控文件变化
- 使用FileSystemWatcher监控文件变化
- FileSystemWatcher文件监控
- 用FileSystemWatcher监视文件变化
- C# FileSystemWatcher监控指定文件
- C# FileSystemWatcher监控指定文件
- C# 利用FTP自动下载xml文件后利用 FileSystemWatcher 监控目录下文件变化并自动更新数据库
- C#中FileSystemWatcher控件实现文件监控
- C#监控文件变化
- Java监控文件变化
- Java监控文件变化
- WatchService监控文件变化
- 监控文件变化
- 谈谈C#文件监控对象FileSystemWatcher使用感受
- 谈谈C#文件监控对象FileSystemWatcher使用感受
- 使用.NET FileSystemWatcher对象监控磁盘文件目录的改变
- C#利用FileSystemWatcher监控对文件的操作
- 在C#使用文件监控对象FileSystemWatcher 实现数据同步
- 原生JavaScript+H5实现简单的音乐播放器
- 看Uboot时会遇到的不懂问题
- 【STM32】STM32之霍尔传感器模块
- Android BadgeView使用介绍 (数字提醒提示)
- Redis实现自动补全
- powershell FileSystemWatcher监控文件变化
- android屏幕旋转显示流程
- 大数据中的“大”究竟指什么?
- 欢迎使用CSDN-markdown编辑器
- 基于MFC的ActiveX控件开发
- gcc-4.4.7升级到gcc-4.8.2
- ajax提交表单,thinkphp5
- Android Vendor Test Suite (VTS) 1
- MSVC工具