文件监视器代码如下:
If DataTables.Contains("文档汇总") = False Then '如果表没有加载
DataTables.Load("文档汇总") '加载表"
End If
Dim ifo As New FileInfo(e.FullPath)
If ifo.Extension = ".doc" Or ifo.Extension = ".docx" Or ifo.Extension = ".png" Or ifo.Extension = ".pdf" Or ifo.Extension = ".xlsx" Or ifo.Extension = ".zip" Or ifo.Extension = ".wps" Or ifo.Extension = ".jpg" Or ifo.Extension = ".pptx" Or ifo.Extension = ".txt" Or ifo.Extension = ".xls" Or ifo.Extension = ".bmp" Or ifo.Extension = ".jpeg" Or ifo.Extension = ".rar" Or ifo.Extension = ".ppt" Or ifo.Extension = ".chm" Or ifo.Extension = ".7z" Or ifo.Extension = ".dotx" Then '非此类文件不加载
If FileSys.GetName(e.Name).StartsWith("~$") Then '不加载以~$"开头的文件
Else
Dim r As Row = Tables("文档汇总").addnew '表增加新行
r("路径") = e.FullPath '文件名及路径赋值到对应列
r("文件名") = FileSys.GetName(e.Name) '获取去掉路径的文件名赋值到对应列
r("创建时间") = ifo.CreationTime
r("最后修改时间") = ifo.LastWriteTime
r("文件大小") = ifo.Length
r("文件类型") = ifo.Extension
End If
Else
End If
DataTables("文档汇总").Save()
当有文件增加时会出现:造型说明无效的字符值 错误提示
请版主指教