How do I make a directory list box using a tree view, like in explorer? I want my program to have more of a professional look, I need my user to chose a directory to work in, but I don't want to use the run-of-the-mill boring one that MSVB6 gives you.
Any ideas? Cheers,
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
In many apps i have seen a dialog box which lets you select a folder...which is displayed in a tree style...(like in explorer) with OK and Cancel button.
How to make that ?
Need Help!--directory Tree In Vb6?
I have no idea how to begin with writing code to populate a tree view control in visual basic , the tough part is it should be recursively looping through a given directory on hard drive and display the folder tree.
any sample code will be welcome.
Directory File Tree
how would you make a directory tree of your entire computer and save it as a single file? ca that be done? i've been looking around for an idea but i'm stumped..
Copy A Directory Tree
I think I've done this in the past but I just can't find any records in my computer.
I have 2 directories, srcDir and dstDir. I want to loop over all files, folders and subfolders of srcDir and copy them to dstDir maintaining the original structure of any subfolders + sub-subfolders, etc in srcDir.
Do I have to use the FSO or what?
Directory Tree View
I'm trying to create a Directory Tree View with the TreeView control, I have successfully created the Directory Structure in the treeview but i don't know how to make it so that if you select the top node, that all the children are checked as well. Does anyone know how to do this or a control that can.
Creating A Non-Existing Directory Tree
Alright... I've got this Function that works, but it's certainly not very elegant and I'm not even entirely sure why it works... But it does, and digging through the forum archives I didn't really find a good solution. So here's what I've got.
Public Sub MakeDir(Path As String)
On Error Resume Next
Dim LoopCount As Integer: LoopCount = 0
Dim oldpos As Integer: oldpos = 1
Dim pos As Integer: pos = 0
Dim StartPos As Integer: StartPos = 1
Do While oldpos <> 0
pos = InStr(oldpos, Path, "", vbTextCompare)
LoopCount = LoopCount + 1
'MsgBox ("Left to Pos: " + Left(Path, pos) + vbCrLf + _
"Loop Count: " + CStr(LoopCount) + vbCrLf + _
"Pos/OldPos: " + CStr(pos) + "/" + CStr(oldpos))
If InStr(StartPos, Mid(Path, StartPos, pos), ":") <> 0 Then
StartPos = InStr(StartPos, Left(Path, pos), ":") + 1
pos = InStr(StartPos, Path, "", vbTextCompare)
Else: ChDir (Mid(Path, StartPos, pos))
oldpos = pos + 1
If InStr(StartPos, Mid(Path, StartPos, pos), ".") Then Exit Do
If Err.Number = 76 Then
MkDir (Left(Path, pos))
ElseIf Err.Number = 75 Then Exit Do
Any thoughts on the subject would be appreciated... This assumes you are passing the full path to a local drive but I know I'm going to run into all kinds of problems when I go to work tomorrow and the app.path is across a network drive and comes up \oldblue*Path*, as well as the first time I encounter a directory with a . in it. Also if anyone knows how to search from right to left through a string it would help as well.
Thanks in advance.
Directory Tree In Access Vb **Resolved**
I am importing a series of files that are all located in the same folder. I need to setup a program that will all the users to change the location of the folder where the files are located. I have tried using the Windows Common Dialogs, but you have to select a file to use that. Is there any way to select a folder programmatically in Access 2000?
Need Help Creating A Backup Directory Tree
I want to write a routine to backup my laptop into an external drive.
One of my directory has subdirectories within subdirectories. Some is one one deep but some are 2, 3 or 4 deep.
I am having trouble creating a routine that would drill down to every subdirectory automatically and back up the files in there.
Can someone help please?
Scan For Files In Directory Tree
I need to automate deleting files from a directory tree that are over 150 days old. I found the code below which I'm using as a proof of concept. It processes the files in the root but I can't figure out how to go below the root directory.
CODE Dim objFSO As New FileSystemObject
Dim objFile As File
Dim objFolder As Folder
Set objFolder = objFSO.GetFolder("Root Directory Path")
For Each objFile In objFolder.Files
List1.AddItem objFile.Name & ", " & objFile.DateCreated
If DateDiff("d", objFile.DateCreated, Date) > 150 Then
List2.AddItem objFile.Name & ", " & objFile.DateCreated
Set objFSO = Nothing
Set objFile = Nothing
Set objFolder = Nothing
Copy Directory Tree Recursion. Broken
I am writing a small GUI less program that copys a directory tree (just the folders not the files) and the resursive function I used to do it dosn't work and I have no idea Why. heres the code
Sub CopyDirTree(ByVal StartDir As String, CopyHere As String)
Dim X As String
Dim Y As String
Dim s As String
Dim currdir As String
Dim dirlist As New Collection
If Right$(StartDir, 1) <> "" Then StartDir = StartDir & ""
'remove current directory from directory list
currdir = dirlist.Item(1)
'find all files and subdirectories in current, add to list
s = Dir$(currdir, vbDirectory)
If (s <> ".") And (s <> "..") Then 'get rid of "." and ".."
's is empty here.
If GetAttr(currdir & s) = vbDirectory Then 'add the subdirectory
dirlist.Add currdir & s & ""
'Set the path to the folders that need to be copied
X = Right$(StartDir, Len(StartDir) - 3)
X = Right$(X, Len(X) - InStr(X, ""))
Y = CopyHere & X
'a file was found (do nothing)
s = Dir$
All I know is the variable s is empty at the indicated spot. I ran this function on D:windows so there is definatly files and folders there.
.hlp Contents Tree Only Works In Original Directory...
My .hlp file contents functions normally in the directory it was made in but nowhere else. Even on the same computer, if i copy the .hlp to another location it doesn't open with a contents tree like in the orig dir.
As far as i can tell all relative paths are correct.....
Opening it with WinHlp32 manually: opens but w/o contents tree except for orig dir.
I read (winhelp.com) that WinHlp automatically builds the contents .GID file so i didn't copy that to new dir. It did make a .GID file.
I did copy the .fts file though since MS recommended it for cd distributions.
Also tried installing it with setup but doesn't open with contents tree either.
In code, i've tried:
strHlp = App.Path & "FASDHELP.HLP"
' first tried:
OpenFile Me.hwnd, strHlp
' which uses ShellExecute Lib "shell32.dll"
' help opens with no contents tree
' then after reading some threads tried:
WinHelp Me.hwnd, strHlp, HELP_CONTENTS, ByVal 0
' which uses WinHelp Lib "user32.dll"
' help opens with no contents tree
' and then:
Shell (GetWinDir() & "WinHelp.exe " & strHlp), vbNormalFocus
' which gave me the error that it's not a windows help file; a new version of help is needed.
I'm pretty much out of ideas... anyone?... vb help meister!!
Directory Tree View, Window Drag
Does anyone know how I can make a Directory Tree view like the one used in WinAmp when you click on Play > Directory. Also, I would like to make my VB 6.0 Forms have the little triangle on the button right like Microsoft program in Win2K/ME/XP that lets you expand the window size when the window is restored.
Like always, thank you in advance.
Need To Recreate The Directory Tree From Windows Explorer...
In several applications, we need to be able to provide the ability to browse through the network as well as the local machines. In the past, we have relied on the Windows Common Control or implementing the SHBrowseForFolder from Shell32 to have access to Network Neighborhood as well as the local machine.
However, new requirements require this to be similar to Windows Explorer...where we are selecting the directory and filename seperate and in conjunction with other selections and controls.
Does anyone know of a control that will reproduce the left pane of Windows Explorer (the directory tree with appropriate icons) or the directory pulldown box used in the Common Control?
Thank you in advance for any suggestions...
How To Collaps A Tree Node With Children And Have It Clear The Children (Tree.Nodes.Remove
I have a tree that has topics, so for example in the following:
I notice that If I colllaps a level it still is retaining the children structor in memory, where the first time through it builds them.
I need that if I collapse the car node it to totaly clears its children and rebuild them again on expansion. Is there a tree function or something that would do this? I think the answer is in using Tree.Nodes.Remove some how, but I am not sure how I would use it here.
Edited by - itmasterw on 6/23/2006 8:12:29 AM
Copy All Files In Current Directory To Temp Directory
ok heres the situation, i need to copy all the files in the app.path directory to another directory....the problem is, with the current code, i can run the app from a folder on the hdd fine, but i get an error when trying to run the app from the root directory of the cdrom....heres my code...btw apppath is a function which returns "D:" when running from the cdrom
error is invalid procedure argument or call, on the copy function
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long'-------- Dim fso As New FileSystemObject Dim Folder2Copy As Folder Set Folder2Copy = fso.GetFolder(AppPath) If Not fso.FolderExists(TempPath & "InternetSignup") Then fso.CreateFolder TempPath & "InternetSignup" Folder2Copy.Copy TempPath & "InternetSignup", True'--------Private Function TempPath() As String 'Function to control the TempPath API Dim strBuffer As String Dim lngLen As Long lngLen = 1024 strBuffer = Space(lngLen) If (GetTempPath(lngLen, strBuffer) > 0) Then strBuffer = Left(strBuffer, InStr(1, strBuffer, vbNullChar) - 1) Else strBuffer = "" End If TempPath = strBuffer End Function
EDIT: Resolved by moving all files to a subfolder on the cdrom
Directory Dialog That Returns A Directory Location Navigated To
Is there an existing control that I can use that will allow me to navigate to a directory with methods to return that directory. The ones coming with VB6 forces one to input a name and then returns the directory path and the file name which then has to be parsed off.
How To Retrieve The Current Directory And Create A Directory In It Using VB Code
I am using common dialog control to get the file name, user wants to save. Also I have a text box in which the user can enter the filename manually. Incase the user enters the filename to be saved manually, how can I validate the filename and Directory using VB. Secondly if the directory path specified by the user doesnot exist , how can i create the directory structure through VB code. Finally how can I retrieve the curr Directory path, incase user only enter the filename.
I would greatly appreciate any help in this regard. Thanks
Treeview Directory Listing With Add Directory Option
Hi there !
What i want is a treeview directory listing with an Add Directory Option which will add a directory and put it in the right place.
the code i have is this but it does not have a create directory option
Public Function vbGetBrowseDirectory(ByVal hwnd) As String
Dim bi As BROWSEINFO
Dim IDL As ITEMIDLIST
Dim r As Long
Dim pidl As Long
Dim tmpPath As String
Dim pos As Integer
bi.hOwner = hwnd
bi.pidlRoot = 0&
bi.lpszTitle = "Select the directory"
bi.ulFlags = BIF_RETURNONLYFSDIRS
'get the folder
pidl = SHBrowseForFolder(bi)
tmpPath = Space$(512)
r = SHGetPathFromIDList(ByVal pidl, ByVal tmpPath)
If r Then
pos = InStr(tmpPath, Chr$(0))
tmpPath = Left(tmpPath, pos - 1)
vbGetBrowseDirectory = ValidateDir(tmpPath)
Else: vbGetBrowseDirectory = ""
Public Function ValidateDir(tmpPath As String) As String
If Right$(tmpPath, 1) = "" Then
ValidateDir = tmpPath
Else: ValidateDir = tmpPath & ""
Upload All Files In Directory To Remote Directory
Hi, I want to upload all files in a specified directory to a remote directory on a FTP server, how could I go about doing that? I was thinking maybe a FileListBox could come into play, but I am probably wrong.
Browse For Directory With Add Directory Buttons.
Alright I'm using the standard api (can be found here at vbforums.com) for showing the browse for folder windows. It is great.
But now I want to use it in my install app.
Nou can I get the add folder button in it???
Thanks in advance,
Deleting All Files From A Directory But Not The Directory Itself?
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFolder "I:Documents and SettingsVaxoPLocal SettingsTemporary Internet Files", True
How can I delete all files and folders in a folder, but not delete the folder itself? (IE delete all files and folders in the temporary internet files folder, but not the temporary folder itself)
All other methods ive tried (nukill, the api, kill) dont work.. this is the only one that has so far.. how can i delete all files except the directory itself?
Winsock And Directory List Box To Get Directory List Of A Remote System
I am using winsock control to transfer the items listed in a directory listbox, to display the list of folder names.The problem is if we move to c:dir1dir2dir3 then again come to c: i am still getting the directory list of c:dir1dir2dir3 .All the changes are done in the directory list box by coding.
i have made a tree with checkboxes, i want to write a code that on its click event the node itself get selected/deselected and if it is a parent node then all of its child should also get selected/deselected. the tree has only two levels. this is the initial code which i write
Dim nd As Node Set nd = Tree.Nodes.Add() nd.Key = "AB" nd.Text = "Address Book" nd.Tag = "HEADS" Set nd = Tree.Nodes.Add() nd.Key = "QR" nd.Text = "Query List" nd.Tag = "HEADS"
Could anyone tell me the basics of using a treeview. Any help would be apprecaited
Can anyone tell me how to make pre order traversal in a tree view control.
I tried with x.firstsibling.index to x.lastsibling.index but problem is it often visits same node more than once because of index.
AVL Tree In VB6 ??
Anyone have a sample of code for an AVL tree structure in VB? It would be a simple tree of numbers or strings.
How do i code a click event for an item in a tree? for example i want to open a report when report1 is clicked in the tree.
Is there an actual click event for a tree.
Another Branch On The Tree!
I am attempting to dynamically populate a TreeView object with data from a database, but keep receiving the Invalid Object error when I try to add a child to a parent. The code so far is...
'Now add all of the root level codes to the tree...
While Not .EOF
'First add the parent node...
tvwCodeList.Nodes.Add , , _
.Fields("CODE"), Left(.Fields("CODE"), 1) & ": " & _
.Fields("LONG_DESCRIPTION") & _
IIf(.Fields("CCSCD_SUBTYPE") = "MPROB", _
" (" & .Fields("OPCS") & ")", _
" (" & .Fields("ICD10") & ")"), _
IIf(.Fields("CCSCD_SUBTYPE") = "MPROB", "picThermom", "picSurgeon")
'Now add a single child node...
tvwCodeList.Nodes.Add .Fields("CODE"), tvwChild, _
"LOAD" & .Fields("CODE"), "Loading...", , "picDisc"
'Move to the next record...
Basically, there are approx 70000 codes I need to display in the TreeView, and to keep speed and memory to a maximum, I have decided to take the approach of when a node expands, other expanded nodes are collapsed, data removed from the underlying nodes, and the selected node to be expanded is then populated.
The error lies in the creation of the temporary "Loading..." node (the second node added in the loop), and I just can't spot what's wrong.
The creation of the first node is fine. Initially, I created only the root nodes, and they worked okay. I thought it might have something to do with the dots on the end of the code (a typical code takes the form, 7........., then it's children will be 70........, 71........, and their children 701....... and so on).
So, if anyone can help, I'd really appreciate it.
Many thanks in advance,
How Tell When No Itemselected In Tree ?
I have a tree view whose root level can be changed by an adjacent dirlistbox. I also have a GO button that will respond to what is selected in the treeview (folder / file). But what I can't figure out is how to tell if there is nothing selected in the tree. This happens when i) the program first starts out, and ii) after I have used the dirlistbox to change the root.
What I was hoping to do, is if nothing is selected, then use the selection in the dirlistbox or the root of the current tree (i havent decided yet)
Thanks for any help.
Tree In Combo Box
What control can I use t display a tree structure in a combo box.. like the one on the open dialog? with the images and all?
Is there such a document that will explain the order/precedence of events for Access objects? I have tried looking in the help file but can't seem to find it.
i am using the windows common control 6's treeview.
there is this option which is the check box.
does anyone know how to make the child node to be uncheck/check automatically when the parent is uncheck/check
please advise. Thanks alot.
how can i place the node names like a tree. i'm new to handling the tree view, please give me a tutorial. thanks in advance..................
Hi i want a treeview to show all files and folders in a specified directory so it ends up looking like this.
--- Folder 1
------ File 1
--- Folder 2
------ File 1
------ File 2
------ File 3
--- Folder 3
------ File 1
How would i do this.
I created a table with 10 different job profiles and with each required skill. Id' like to use a treeview to display them, and i don't have a clue on how to elaborate it.
profile 1; skill 1
profile 1; skill 2
profile 1; skill 3
profile 1; skill 4
profile 2; skill 1
profile 1; skill 2
I have a TreeView which I am using a piece of code posted on this forum by Garrett Sever that changes the background colour of the treeview.
This works, but the one problem I'm having is when a user selects a node the selected item's background colour can clash with it's foreground colour. I belive it gets it colours from the desktop colours. Is there anyway I can override this and use my own colours for the selection ?
Can I delete a folder, all its subfolders and files, all their subfolders and files, etc. Without having to loop through each folder deleting files individually?
Is it posible to add some folders into windows's system tree.
--My added folder or file
Is there any API function or I need to investigate my system registry manualy?