我正在使用一个在多个文件夹中提交dcm文件的工具。 现在我正在尝试添加一个复选框来管理您要提交的确切文件夹 因此,如果我想在子文件夹中包含文件,我将按下复选框,如果不是我将不选中。 现在的问题是,即使未选中复选框,我也无法排除子文件夹的加载
这是我正在处理的功能:
Sub CheckBox1CheckedChanged()
If IO.Directory.GetDirectories(CWPathTB.Text).Length > 1 AndAlso checkBox1.Checked= False Then
'how to clear the subfolders and make them unseen in this condition
LoadChangedFiles2()
Else
FilesGrid.Rows.Clear()
LoadChangedFiles()
End If
End Sub
非常感谢您的帮助:)
...
功能:
Public Sub LoadChangedFiles2()
'loading all the modified , added and removed files only in the top directory into files grid
Dim b,j As Integer
Dim PushokClientt As New PushOkSvn.SVNClient
Dim ModiFiles As New ArrayList
Dim ConflFiles As New ArrayList
FileLocalPos1.Clear()
FileList1.Clear()
ModFileArr1.Clear()
ConfFileArr1.Clear()
AddedFileArr1.Clear()
RemovedFileArr1.Clear()
Dim LocDir As New IO.DirectoryInfo(CWPath)
Dim ignorSharcc As Boolean = False
Dim FInfoLoc() As IO.FileInfo = LocDir.GetFiles("*.dcm",IO.SearchOption.TopDirectoryOnly)
Dim FileInfoLoc As IO.FileInfo
For Each FileInfoLoc In FInfoLoc
If FileInfoLoc.FullName.Substring(FileInfoLoc.FullName.Length - 4 , 4 ) = ".dcm" Then
If Not FileInfoLoc.FullName.Contains("sharcc") Then
Dim TempFileName() As String
Dim FileName As String
TempFileName = FileInfoLoc.FullName.Split("\")
FileName = TempFileName(TempFileName.Length - 1)
If Not FileLocalPos1.Contains(FileName)Then
FileLocalPos1.Add(FileInfoLoc.FullName , FileName )
FileList1.Add(FileName)
Else
MsgBox("In Pfad exist two .dcm files with the same name . Choose an exacter Pfad . ")
Exit Sub
End If
Else
ignorSharcc = True
End If
End If
Next
If ignorSharcc = True Then
MsgBox("Sharcc folder has been ignored.")
End If
Call checkStatus2(CWPath, PushokClientt)
j=0
For b = 0 To ModFileArr1.Count - 1
Dim Filerow1 As String() = {False, ModFileArr1.Item(b).ToString, "Modified", FileLocalPos1.Item(ModFileArr1.Item(b).ToString)}
DcmComm.FilesGrid.Rows.Add(Filerow1)
j = j + 1
Next
For b = 0 To ConfFileArr.Count - 1
Dim Filerow1 As String() = {False, ConfFileArr1.Item(b).ToString, "Conflicted", FileLocalPos1.Item(ConfFileArr1.Item(b).ToString)}
DcmComm.FilesGrid.Rows.Add(Filerow1)
DcmComm.FilesGrid.Rows(j).DefaultCellStyle.BackColor = Color.DarkGray
DcmComm.FilesGrid.Rows(j).ReadOnly = True
MsgBox(ConfFileArr1.Item(b).ToString & " is out of date! Please update first! ")
j = j + 1
Next
For b = 0 To AddedFileArr1.Count - 1
Dim row1 As String() = {False, AddedFileArr1.Item(b).ToString, "Added", FileLocalPos1.Item(AddedFileArr1.Item(b).ToString)}
DcmComm.FilesGrid.Rows.Add(row1)
j = j + 1
Next
For b = 0 To RemovedFileArr1.Count - 1
Dim row1 As String() = {False, RemovedFileArr1.Item(b).ToString, "Removed", ""}
DcmComm.FilesGrid.Rows.Add(row1)
j = j + 1
Next
Exit Sub
End Sub
..........................
,错误出现在这一行:
Dim Filerow1 As String() = {False, ModFileArr1.Item(b).ToString, "Modified", FileLocalPos1.Item(ModFileArr1.Item(b).ToString)}
答案 0 :(得分:0)
您需要将GetDirectories overload与搜索选项参数一起使用:
IO.Directory.GetDirectories(CWPath, "*.*", IO.SearchOption.TopDirectoryOnly)