|
-
Aug 20th, 2001, 09:00 AM
#1
Thread Starter
Addicted Member
Create Tree from list of files
I have a list of files like that:
Code:
c:\folder1\file.txt
c:\folder1\file2.txt
c:\folder1\file3.txt
c:\folder1\file4.txt
c:\folder1\subfolder\file.txt
c:\folder1\subfolder\file1.txt
c:\folder1\subfolder\file2.txt
c:\folder1\subfolder\file3.txt
c:\folder1\subfolder\test\file.txt
c:\folder1\subfolder\test\file1.txt
c:\folder1\subfolder\test\file2.txt
c:\folder2\file.txt
c:\folder2\subfolder\file.txt
AND SO ON
Can someone tell me any possible way to make a tree out of that data?
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Aug 20th, 2001, 09:25 AM
#2
Fanatic Member
Now, how do you mean, make a tree? Do you want the info sent to a treeview, or do you want an ASCII file generated that does this:
Code:
c:\folder1\file.txt
file2.txt
file3.txt
file4.txt
subfolder\file.txt
file1.txt
file2.txt
file3.txt
test\file.txt
file1.txt
file2.txt
c:\folder2\file.txt
subfolder\file.txt
-
Aug 20th, 2001, 01:29 PM
#3
Thread Starter
Addicted Member
I'd like to send it to treeview:
like this:
Code:
c:\
|--folder
| \--subfolder
| \-test
| |--file1.txt
| \--file2.txt
\--folder2
\--file1.txt
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Aug 20th, 2001, 01:46 PM
#4
Are you getting this as a string??? Or you want to actually go through the folders on your machine and populate the treeview?
-
Aug 21st, 2001, 06:06 AM
#5
Thread Starter
Addicted Member
Each line is a string, for example:
Code:
Dim tmpStr() As String, tmpS As String
ReDim tmpStr(20) As String
For I=1 To 4
tmpS = "C:\Folder" & I
For J = 1 to 5
tmpStr((I - 1) * 4) + J) = tmpS & "\file" & J & ".txt"
Next
Next
Here is an example of array with 20 items. From that data I need to populate treeview.
Suggestions are very appreciated and welcome.
P.S.: If code has errors, doesn't matter I wrote it in a minute just for example. The real code is much more complex.
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Aug 22nd, 2001, 09:08 AM
#6
Thread Starter
Addicted Member
Mhm...
Does noone have not even slightest idea what to do?
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Aug 22nd, 2001, 09:31 AM
#7
Registered User
Sounds like a lot of work, what do you need it for?
-
Aug 22nd, 2001, 09:46 AM
#8
Not that much work Something like this:
VB Code:
Private Sub Form_Load()
Dim arrTemp(12) As String
Dim i As Integer
Dim j As Integer
Dim arrFolders() As String
Dim nod As Node
Dim strKey As String
Dim strPrevKey As String
'assuming that the array holds these files/folders
arrTemp(0) = "c:\folder1\file.txt"
arrTemp(1) = "c:\folder1\file2.txt"
arrTemp(2) = "c:\folder1\file3.txt"
arrTemp(3) = "c:\folder1\file4.txt"
arrTemp(4) = "c:\folder1\subfolder\file.txt"
arrTemp(5) = "c:\folder1\subfolder\file1.txt"
arrTemp(6) = "c:\folder1\subfolder\file2.txt"
arrTemp(7) = "c:\folder1\subfolder\file3.txt"
arrTemp(8) = "c:\folder1\subfolder\test\file.txt"
arrTemp(9) = "c:\folder1\subfolder\test\file1.txt"
arrTemp(10) = "c:\folder1\subfolder\test\file2.txt"
arrTemp(11) = "c:\folder2\file.txt"
arrTemp(12) = "c:\folder2\subfolder\file.txt"
With TreeView1
.Sorted = True
For i = 0 To UBound(arrTemp)
arrFolders = Split(arrTemp(i), "\")
strKey = ""
For j = 0 To UBound(arrFolders)
strKey = strKey & arrFolders(j) & "\"
On Error Resume Next
If j = 0 Then
Set nod = .Nodes(strKey)
If nod Is Nothing Then Set nod = .Nodes.Add(, , strKey, arrFolders(j))
Else
Set nod = .Nodes.Add(strPrevKey, tvwChild, strKey, arrFolders(j))
End If
strPrevKey = strKey
nod.Sorted = True
nod.EnsureVisible
Next
Next
End With
End Sub
-
Aug 22nd, 2001, 09:47 AM
#9
Thread Starter
Addicted Member
I have a list of files (in text file) and from that I need to make a tree (in treeview).
The program has it's own database (collection-driven) and it saves filenames (with paths and other data) in file and then it loads it to a treeview...
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Aug 22nd, 2001, 09:51 AM
#10
Thread Starter
Addicted Member
Interesting code.....
I'll check it out...
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|