我有一个小问题。在程序结束时,它应该删除一个文件夹。
为了拒绝删除包含某个单词的文件夹,我想检查一个字符串(directory.fullname.tostring)是否包含存储在字符串数组中的任何元素。字符串数组包含说明异常词的字符串。
这是我走了多远,我知道解决方案与此处所述相反:
If Not stackarray.Contains(dir.FullName.ToString) Then
Try
dir.Delete()
sw.WriteLine("deleting directory " + dir.FullName, True)
deldir = deldir + 1
Catch e As Exception
'write to log
sw.WriteLine("cannot delete directory " + dir.ToString + "because there are still files in there", True)
numbererror = numbererror + 1
End Try
Else
sw.WriteLine("cannot delete directory " + dir.ToString + "because it is one of the exception directories", True)
End If