Results 1 to 3 of 3

Thread: 2 Questions

  1. #1

    Thread Starter
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I know how to get the filesize of a file, but couldn't figure out how to get the filesize of a dir.. anyone?

    and second..
    Is it possible to stop all active tasks your program is doing (finding files in directories) when pressing a cancel button? (i know this one sounds stupid)

    Thanks in advance..
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    1. Loop through every file in the directory and add the total.

    Code:
    stFileList = dir$("c:\myDir\*.*")
    
    do while stFileList <> ""
      lSize = lSize + filelen(stfilelist)
      stfilelist = dir
    loop
    2. You will need to add a exit clause to the function. E.g a boolean. When the user clicks the cancel button, set the boolean = true.

    Code:
    Priavte Sub cmdCancel_Click()
      blCancel = True
    End Sub
    
    Priavte Sub myLoop()
    
      stFileList = dir$("c:\myDir\*.*")
     
      do while (stFileList <> "") and (blcancel = False)
        lSize = lSize + filelen(stfilelist)
        stfilelist = dir
        doevents
      loop
    
    end sub
    Iain, thats with an i by the way!

  3. #3

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