.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

Implementing the changes to your TreeView

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh

Implementing the changes



Ok, time to change the recursive function with the question you ask yourself. You may have to do some tries or test before getting something to work perfectly.  Normally, if you analyze your problem and ask yourself a lot of question, you should be able to make the changes easily.

Before :


Private Sub findfiles(Optional dirPath As String = "c:\temp\"Optional String_to_Search As String = "*.dll")



For Each foundFile As String In My.Computer.FileSystem.GetFiles( _
      dirPath, FileIO.SearchOption.SearchTopLevelOnly, String_to_Search)

       oForm2.ListBox1.Items.Add(foundFile)

Next

For Each foundDirectory As String In My.Computer.FileSystem.GetDirectories( _ dirPath, FileIO.SearchOption.SearchTopLevelOnly)

      findfiles(foundDirectory) ''recursive search file : re-use "himself"

Next




For Each foundFile As String In My.Computer.FileSystem.GetFiles( _
       dirPath, FileIO.SearchOption.SearchTopLevelOnly, String_to_Search) 'recursive search file : you need to limit your search to 1 single directory : and put extension in search argument

       'oForm2.ListBox1.Items.Add(foundFile)
       'TreeView1.Nodes.Add(foundFile)

       no1.Nodes.Add(foundFile)

Next

For Each foundDirectory As String In my.Computer.FileSystem.GetDirectories( dirPath, FileIO.SearchOption.SearchTopLevelOnly)

    'findfiles(foundDirectory) ''recursive search file : re-use "himself"
     Dim no2 As TreeNode
     no2 = no1.Nodes.Add(foundDirectory)
     findfiles(no2, foundDirectory, String_to_Search) ''recursive search file : re-use "himself"
Next



After:


Private Sub findfiles(no1 As TreeNode, Optional dirPath As String = "c:\temp\"Optional String_to_Search As String = "*.dll")


I added no1 for node one, this will represent the main node or current node. It works exactly the same way compared to dirPath. dirPath acts like the current path. All the stuff in the argument in a recursive function are constantly reused and is always base from the current data. The current data here in this example is the current node with a current directory.



For Each foundFile As String In My.Computer.FileSystem.GetFiles( _
       dirPath, FileIO.SearchOption.SearchTopLevelOnly, String_to_Search) 'recursive search file : you need to limit your search to 1 single directory : and put extension in search argument

       'oForm2.ListBox1.Items.Add(foundFile)
       'TreeView1.Nodes.Add(foundFile)

       no1.Nodes.Add(foundFile)

Next

For Each foundDirectory As String In my.Computer.FileSystem.GetDirectories( dirPath, FileIO.SearchOption.SearchTopLevelOnly)

    'findfiles(foundDirectory) ''recursive search file : re-use "himself"
     Dim no2 As TreeNode
     no2 = no1.Nodes.Add(foundDirectory)
     findfiles(no2, foundDirectory, String_to_Search) ''recursive search file : re-use "himself"
Next




And here how I decided to start my findfiles function. I injected a first node called MAIN.


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgsHandles Button1.Click
        'position()
        'Fill_TreeView()
        Me.TreeView1.Nodes.Add("MAIN")
        Dim no As TreeNode
        no = Me.TreeView1.Nodes.Item(0)
        findfiles(no, "C:\ProgramData\Microsoft\Windows\Start Menu""*.lnk")
    End Sub



Previous Page : Analyse your code in Visual Basic <<<= = =








About 

I invite you to visit my blog for more articles and leave a comment. Check Technologies represents more than 10 years .... Computer and computer aided design.


235 Adrien-Provencher
Beloeil, (Qu�bec), J3G 0C8, Canada
Tel : 514-705-7690
emal: info@checktechno.ca



Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel Implementing the changes to your TreeView, Diterbitkan oleh scodeaplikasi pada Sabtu, 15 Desember 2012. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to