By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,802 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Copying CD directory contents to text or memo field

P: 4
Hi there,

I've tried to search on this topic but had little luck. Essentially, i am constructing a simple CD library database and would like to be able to capture the contents of the CD (either folder names or file names) to a memo field within the database.

I can do this manually using the freeware app JR Directory Printer but would like to be able to build this functionality into the database activated by a button click.

I am running Access 2002

Any suggestions much appreciated.

Kind regards

DFG
Feb 6 '08 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,327
You'll want to look at the FileSystem object. It lets you return information about files.
Feb 6 '08 #2

FishVal
Expert 2.5K+
P: 2,653
Hello, DFG.

You'll need to write a simple recursive function with the following logic (in pseudocode).
Expand|Select|Wrap|Line Numbers
  1. Function ScanFolder (fldFolder)
  2.     add fldFolder name to the memo
  3.     For Each fldMySubFolder in fldFolder.SubFolders
  4.         ScanFolder fldMySubFolder  'call itself
  5.     Next
  6.     For Each filFile in fldFolder.Files
  7.         add filFile name to the memo
  8.     Next
  9. End Function
  10.  
And invoke the function passing reference to root folder. It then will scan the whole filesystem tree.

All necessary classes to implement this in a real code you may find in "Microsoft Scripting Runtime" library. See the tip of the week - TheScripts Tip of the Week #43 - Microsoft Scripting Runtime #1.
Particulary you'll need the following classes.
  • Scripting.Drive (RootFolder property)
  • Scripting.Folder (Files, SubFolders properties)
  • Scripting.File (various properties)

Feel free to ask additional questions if you'll encounter difficulties in coding.

Regards,
Fish
Feb 6 '08 #3

P: 4
Hi Fish, thanks for your pointers, it should head me in the right direction though being a bit new to all this i may be back for more help later. Cheers. DFG

Hello, DFG.

You'll need to write a simple recursive function with the following logic (in pseudocode).
Expand|Select|Wrap|Line Numbers
  1. Function ScanFolder (fldFolder)
  2.     add fldFolder name to the memo
  3.     For Each fldMySubFolder in fldFolder.SubFolders
  4.         ScanFolder fldMySubFolder  'call itself
  5.     Next
  6.     For Each filFile in fldFolder.Files
  7.         add filFile name to the memo
  8.     Next
  9. End Function
  10.  
And invoke the function passing reference to root folder. It then will scan the whole filesystem tree.

All necessary classes to implement this in a real code you may find in "Microsoft Scripting Runtime" library. See the tip of the week - TheScripts Tip of the Week #43 - Microsoft Scripting Runtime #1.
Particulary you'll need the following classes.
  • Scripting.Drive (RootFolder property)
  • Scripting.Folder (Files, SubFolders properties)
  • Scripting.File (various properties)

Feel free to ask additional questions if you'll encounter difficulties in coding.

Regards,
Fish
Feb 6 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.