请问怎样优化以下代码, 当删除行时,一起删除四个文件夹下与出厂编号相同的文。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