Not that I know of. Here's some kind of pseudo code - you'll have to fill in
the blanks
Class FilePath
Public ChildCollection as Collection
Public Address as string
Public DirectoryPath as string
Public FileName as string
ParentAddress as string
End Class
Dim TempCollection as new Collection
Dim BaseFilePath as FilePath 'the root object
'open a stream from the file and read each line into a local variable.
Return EOF = true when finished with the last line
dim StrTmp as stirng
Dim CountOfSlashes as long
Dim StringIndex as long
dim LastSlash as boolean
dim CurrentPath as filePath
Do until EOF
CurrentPath = new FilePath
StringIndex = 0
strTmp = readLine()
CurrentPath.Address = StrTmp
if instr(StrTmp, ".") > 0 then
'this is a file, so we have to grab the directory path
stripping off the filename
StringIndex = StrTmp.LastIndexOf("\")
CurrentPath.DirectoryPath = Left(StrTmp, StringIndex + 1)
'should get the C:\MyFolder\ section of C:\MyFolder\MyFile.txt
FileName = Mid(StrTmp, StringIndex + 1) ' should get
MyFile.txt part of the above sample string
else
CurrentPath.DirectoryPath = StrTmp
FileName = "" 'set to ZLS for testing purposes
end if
'now get the parent address which should be the same for every line
if instr(StrTmp, "\", 3) > 0 then 'start at the 4th character in the
string (i.e. start just after the first slash in C:\MyFolder\MyFile.txt) and
see if there are any following slashes
StringIndex = StrTmp.LastIndexOf("\")
'now add the whole string up to this point as the parent
address
currentPath.ParentAddress = left(StrTmp, StringIndex)
'should add the whole of strtmp up to the last "\" as the parent address
end if
TempCollection.add(CurrentPath)
Loop
'now it should simple be a case of iterating through the collection and
adding the object in a structured way to the base object.
Hope this helps - basically the idea is that you parse the strings to break
them up into the parent section, the filename and the current address. You
then should compare the currentAddress to the parentAddress and be able to
group them into a single recursive set of objects. Once you have them in a
nice useable structure you should be able to draw the tree view very easily.
You could also persist the object tree into memory for later use
Nick
Bob Hollness said:
do you know of anyone of telling VB that each entry in the treeview must be
unique?