|
-
Jun 11th, 2002, 09:37 PM
#1
Thread Starter
PowerPoster
FSO to Dir
Can anyone help me convert this function that I am using the FileSystemObject with to it's Dir counterpart. I don't want to include the scripting runtime when I release the program I am working on.
Code:
'load code folder and two subfolders deep into a treeview
Public Sub LoadCodeTree()
mydir = App.Path & "\Code\"
If Dir(mydir, vbDirectory) = "" Then MkDir mydir
tvwFolders.Nodes.Add , , "root", "Categories", 2
tvwFolders.Nodes(1).Expanded = True
For Each fldr In FSO.GetFolder(mydir).SubFolders
tvwFolders.Nodes.Add "root", tvwChild, fldr.Name, fldr.Name, 2
For Each fldr2 In FSO.GetFolder(fldr).SubFolders
tvwFolders.Nodes.Add fldr.Name, tvwChild, fldr.Name & fldr2.Name, fldr2.Name, 2
Next
Next
End Sub
and this one:
Code:
'load all the .code files into a listview
For Each file In FSO.GetFolder(mydir).Files
If Right(file.Name, 5) = ".code" Then
lstCode.ListItems.Add , , Left(file.Name, InStrRev(file.Name, ".code") - 1), , 1
End If
Next
and this one:
Code:
'remove all files in the folder, then remove the folder
If FSO.GetFolder(mydir).Files.Count > 0 Then
For Each file In FSO.GetFolder(mydir).Files
FSO.DeleteFile mydir & "\" & file.Name, True
Next
End If
RmDir mydir
tvwFolders.Nodes.Remove tvwFolders.SelectedItem.Index
Thanks guys.
-
Jun 12th, 2002, 01:08 AM
#2
Thread Starter
PowerPoster
I know someone who hates the FSO knows how to do this... but if no one will help, I'll just keep the FSO.
-
Jun 12th, 2002, 01:11 AM
#3
PowerPoster
I like FSO.
I say that because every time I do, I attract all the people who hate FSO. They will all pour into this thread and give you more information than you ever wanted to know about using Dir() and you'll have me to thank for it.
BTW, this question gets asked 3 times a week. You can probably find an answer in about a minute if you search.
-
Jun 12th, 2002, 01:19 AM
#4
Thread Starter
PowerPoster
Yeah but I'm too lazy to do it myself, and I thought that there might be someone here that is as bored as me and would like to convert it for me. I guess I'll have to do it though, cause all the people that hate FSO don't come around here much anymore... filburt, jbptennisman, etc. they are all at their own forums now.
-
Jun 12th, 2002, 01:20 AM
#5
PowerPoster
but you posted the question, like, 7 hours ago.
-
Jun 12th, 2002, 01:24 AM
#6
Thread Starter
PowerPoster
Originally posted by cafeenman
but you posted the question, like, 7 hours ago.
Just cause I haven't got out of my seat in 7 hours doesn't mean you can be mean to me! lol j/k. I got up once to go to get my Vanilla coke. ick. I'm just gonna stick with FSO for now, cause I have to figure out *** went wrong with my code. It was working fine earlier, and I didn't change the part of the code that is erroring, but now it errors. It's some code that colors keywords in a richtextbox.... stupid code! lol
Ok i'm gonna stop babbling now.
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
|