Results 1 to 6 of 6

Thread: FSO to Dir

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    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.
    <removed by admin>

  2. #2

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    I know someone who hates the FSO knows how to do this... but if no one will help, I'll just keep the FSO.
    <removed by admin>

  3. #3
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    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.

  4. #4

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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.
    <removed by admin>

  5. #5
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    but you posted the question, like, 7 hours ago.

  6. #6

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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.
    <removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width