private void updateFileList(ref FileChangeInfo fileChangeInfo) { if (!isAttentionFile(ref fileChangeInfo)) { return; } if (!File.Exists(fileChangeInfo.fullPath)) { return; } if (!_fileIndexDic.ContainsKey(fileChangeInfo.fullPath)) { addChangedFileRow(ref fileChangeInfo); } else { if (isInDownload && fileChangeInfo.fullPath == downloadingFile) { return; } FileChangeGridView.Rows[_fileIndexDic[fileChangeInfo.fullPath]].Cells[1].Value = fileChangeInfo.changeTime; FileChangeGridView.Rows[_fileIndexDic[fileChangeInfo.fullPath]].Cells[2].Value = fileChangeInfo.changeType.ToString(); } resizeColumn(0); return; }
private void addChangedFileRow(ref FileChangeInfo fileChangeInfo) { DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell fileFullPath = new DataGridViewTextBoxCell(); fileFullPath.Value = fileChangeInfo.fullPath; row.Cells.Add(fileFullPath); DataGridViewTextBoxCell changeTime = new DataGridViewTextBoxCell(); changeTime.Value = fileChangeInfo.changeTime; row.Cells.Add(changeTime); DataGridViewTextBoxCell changTypeName = new DataGridViewTextBoxCell(); changTypeName.Value = fileChangeInfo.changeType.ToString(); row.Cells.Add(changTypeName); //DataGridViewComboBoxCell comboxcell = new DataGridViewComboBoxCell(); //row.Cells.Add(comboxcell); Action <DataGridViewRow> addRowAction = (data) => { FileChangeGridView.Rows.Add(data); }; if (FileChangeGridView.InvokeRequired) { ActionCall <DataGridViewRow> addRow = new ActionCall <DataGridViewRow>((DataGridViewRow rowData) => { return(FileChangeGridView.Rows.Add(rowData)); }); int index = (int)this.Invoke(addRow, row); _fileIndexDic.Add(fileChangeInfo.fullPath, index); } else { FileChangeGridView.Rows.Add(row); } }
private void FileSystemWatcher_Changed(object sender, FileSystemEventArgs e) { FileChangeInfo fileChangeInfo = new FileChangeInfo(); fileChangeInfo.fullPath = e.FullPath; fileChangeInfo.changeType = e.ChangeType; fileChangeInfo.changeTime = DateTime.Now.ToString(); MonitorFileChanged?.Invoke(sender, fileChangeInfo); }
private bool isAttentionFile(ref FileChangeInfo fileChangeInfo) { string FileName = Path.GetFileName(fileChangeInfo.fullPath); foreach (var item in _fileFilter) { if (FileName.EndsWith(item)) { return(true); } } return(false); }
private void FileWachter_MonitorFileChanged(object sender, FileChangeInfo fileChangeInfo) { updateFileList(ref fileChangeInfo); }