PDA

View Full Version : سوال: پیداکردن زیر مجموعه های یک فولدر



fazelm
یک شنبه 01 شهریور 1388, 22:09 عصر
چگونه می توان زیر مجموعه های یک فولد را در وی بی دات نت پیداکرد؟

fazelm
یک شنبه 01 شهریور 1388, 22:10 عصر
کسی نیست جواب بده ؟

Hossis
یک شنبه 01 شهریور 1388, 23:06 عصر
جواب سریع

ListBox1.Items.AddRange(IO.Directory.GetDirectorie s("d:\"))

Hossis
یک شنبه 01 شهریور 1388, 23:07 عصر
جواب مفصل :‌من یک سورس دارم که تمام پوشه های یک مسیر مشخص رو تو treeview می ریزه

یک پروژه ایجاد کرده و یک treeview با نام tv و یک لیست ویو با نام LV ایجاد کن
بعد کد زیر را در فرم وارد کن




Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Y As Integer = TV.Nodes.Count
For u As Long = 0 To IO.DriveInfo.GetDrives.Count - 1
TV.Nodes.Add(IO.DriveInfo.GetDrives.GetValue(u).To String)
Next
pic.Left += 1
End Sub
Private Sub LV_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LV.MouseDoubleClick
LV.Tag &= "\" & LV.SelectedItems(0).Text
LV.Tag = LV.Tag.ToString.Replace("\\", "\")
' Dim nFile As String = TV.SelectedNode.FullPath & "\" & LV.SelectedItems(0).Text
Try
Process.Start(LV.Tag) ' nFile)
Catch ex As Exception
End Try
End Sub
Private Sub TV_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TV.AfterSelect
Dim c As String = e.Node.FullPath
Dim Y As Integer = TV.Nodes.Count
drive = My.Computer.FileSystem.GetDirectoryInfo(c)
If e.Node.Nodes.Count <= 0 Then
For i As Int32 = 0 To drive.GetDirectories.Count - 1
If drive.GetDirectories.GetValue(i).ToString = "System Volume Information" Then Continue For
e.Node.Nodes.Add("F" & Y, drive.GetDirectories.GetValue(i).ToString, "fc")
Next
End If
' Img.Images.Clear()
LV.Items.Clear()
LV.Visible = False
For i As Int64 = 0 To drive.GetFiles.Count - 1
Try
Dim F As String = drive.GetFiles.GetValue(i).ToString
Dim ff As String = c & "\".Replace("\\", "\") & F ' F.Substring(F.IndexOf(".") + 1)
If F.Substring(F.IndexOf(".") + 1) = "ico" Then

Img.Images.RemoveByKey("txt")
Try
Img.Images.Add("txt", Drawing.Image.FromFile(ff))
Catch ex As Exception
End Try
End If
LV.Items.Add("File" & Y, F, "txt")
My.Application.DoEvents()
Catch ex As Exception
End Try
Application.DoEvents()
Next
LV.Tag = c
LV.Visible = True
End Sub