Computer Science Canada Directory Reading |
Author: | srbman [ Sun Apr 30, 2006 11:11 am ] |
Post subject: | Directory Reading |
I was wondering if anyone knew a way to read all the file names in a given directory and copy them into a text file. I would prefer the code in any of the following: Flash AS1.x or 2.x, Visual Basic 6.x, or Turing if possible. Thanx |
Author: | GlobeTrotter [ Sun Apr 30, 2006 11:24 am ] | ||||||
Post subject: | |||||||
Here's a module I wrote in vb6 (with the help of some tutorials on some Win32 functions) that takes in a directory as an arguments, as well as whether or not it should check sub-folders as well. If it should check sub-folders, it recursively searches those folders for files or folders. It is not perfect, unfortunately, and probably could be optimized quite a deal. But still, it works for me. This is the primary module:
You may also need these secondary functions/procedures
To call it, you would go like this:
When I talked about it not being perfect, I was primarily referring to the need to use the RemoveDupes function. For some reason, which I can't figure out, my ListFiles function will sometimes output duplicate filenames. But I employed a quick fix, and it shouldn't do that anymore. |
Author: | srbman [ Sun Apr 30, 2006 11:57 am ] |
Post subject: | |
your code works until it gets to strFixedUBound and then it says "sub or fucntion not defined" i put the module code in "module1" the secondary procedures in "form1" called everything in a button on form1 do i need to add or change anything to make it work? (i changed the target directory to a directory on my computer) |
Author: | GlobeTrotter [ Sun Apr 30, 2006 2:05 pm ] | ||||
Post subject: | |||||
Oh, my bad. Also include these small functions:
strFixedUBound just returns the upper bound of an array (almost identical to UBound) except it returns -1 if the array is empty. You also will probably need these functions too:
It should work now, sorry. Let me know if it works. |
Author: | srbman [ Sun Apr 30, 2006 2:47 pm ] |
Post subject: | |
thanx it works, is there a way to get rid of the album art jpegs that it gives in a music folder? (for example albumart_{f52fbda5-47e8-4d41-aa76-9bd0b3b11ebb}_large.jpg ) thanx again |
Author: | GlobeTrotter [ Sun Apr 30, 2006 4:52 pm ] | ||
Post subject: | |||
You could always write a function that loops through each file and checks if the filetype is ".mp3", and if the filetype isn't mp3, remove it. It would not be at all difficult. Here are some functions I've already made that may be useful for this:
|
Author: | srbman [ Mon May 01, 2006 7:09 pm ] |
Post subject: | |
thanx ill try working on it next weekend when i have more time. |
Author: | Andy [ Tue May 02, 2006 12:27 pm ] |
Post subject: | |
use system call "dir > blah.txt" then parse it ![]() |