以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何删除文件夹多余的文件? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=58898) |
||||
-- 作者:lyfxybc -- 发布时间:2014/10/26 9:22:00 -- 如何删除文件夹多余的文件? 如何删除文件夹多余的文件? 假设有表A中有一列,每行单元格存放文件夹的文件名,当文件夹文件名和单元格文件名不一样时,删除文件夹中单元格没有的文件。 文件夹中5.doc在单元格中没有则删除。用代码如何写(按钮中) [此贴子已经被作者于2014-10-26 9:23:57编辑过]
|
||||
-- 作者:lyfxybc -- 发布时间:2014/11/2 21:21:00 -- 请问下列代码为何不能完成上述要求 BeforeDeleteDataRow If FileSys.FileExists(ProjectPath & "Bfbak\\" & e.DataRow("第一列")) Then FileSys.DeleteFile(ProjectPath & "Bfbak\\" & e.DataRow("第一列")) Else For Each File As String In FileSys.GetFiles(ProjectPath & "Bfbak\\") If FileSys.FileExists(file) Then If file <> ProjectPath & "Bfbak\\" & e.DataRow("第一列") FileSys.DeleteFile(file) End If End If Next End If 要求: 删除第四行3.txt的同时删除项目文件夹ProjectPath & "Bfbak\\的3.txt,同时判断项目文件夹ProjectPath & "Bfbak\\下若果文件和表中第一列文件名不同的够删除掉。
[此贴子已经被作者于2014-11-2 21:25:05编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2014/11/2 21:24:00 -- 删除多余文件,参考
For Each File As String In FileSys.GetFiles(ProjectPath & "Bfbak\\") |
||||
-- 作者:lyfxybc -- 发布时间:2014/11/2 21:29:00 -- 非常感谢,达到了我的要求,再次感谢 |
||||
-- 作者:wusim -- 发布时间:2016/5/17 21:42:00 -- 请问怎样优化以下代码, 当删除行时,一起删除四个文件夹下与出厂编号相同的文。 Dim f As String = ProjectPath & "资料备份目录\\质量证明书\\" & Tables("基本信息表").Current("出厂编号") & ".xls" If FileSys.FileExists(f) Then For Each File As String In FileSys.GetFiles(ProjectPath & "资料备份目录\\质量证明书\\") Dim fdr As DataRow = e.DataTable.Find("出厂编号 = \'" & FileSys.GetName(file) & "\'") If fdr Is Nothing Then FileSys.DeleteFile(file) End If Next End If Dim f1 As String = ProjectPath & "资料备份目录\\注册登记表\\" & Tables("基本信息表").Current("出厂编号") & ".xls" If FileSys.FileExists(f1) Then For Each File As String In FileSys.GetFiles(ProjectPath & "资料备份目录\\注册登记表\\") Dim fdr As DataRow = e.DataTable.Find("出厂编号 = \'" & FileSys.GetName(file) & "\'") If fdr Is Nothing Then FileSys.DeleteFile(file) End If Next End If Dim f2 As String = ProjectPath & "资料备份目录\\自检记录\\" & Tables("基本信息表").Current("出厂编号") & ".xls" If FileSys.FileExists(f2) Then For Each File As String In FileSys.GetFiles(ProjectPath & "资料备份目录\\自检记录\\") Dim fdr As DataRow = e.DataTable.Find("出厂编号 = \'" & FileSys.GetName(file) & "\'") If fdr Is Nothing Then FileSys.DeleteFile(file) End If Next End If Dim f3 As String = ProjectPath & "资料备份目录\\告知书\\" & Tables("基本信息表").Current("出厂编号") & ".xls" If FileSys.FileExists(f3) Then For Each File As String In FileSys.GetFiles(ProjectPath & "资料备份目录\\告知书\\") Dim fdr As DataRow = e.DataTable.Find("出厂编号 = \'" & FileSys.GetName(file) & "\'") If fdr Is Nothing Then FileSys.DeleteFile(file) End If Next End If |
||||
-- 作者:大红袍 -- 发布时间:2016/5/17 22:09:00 -- Dim cs() As String = {"质量证明书", "注册登记表", "自检记录", "告知书"} For Each c As String In cs |