Folder content to memo field ? (1 Viewer)

F

francois

Guest
I want to copy the directory/folder structure of a CD disk into a memo field , including all the file names .
Any help out there ?
 

jonesy

Registered User.
Local time
Today, 17:16
Joined
Jan 23, 2003
Messages
17
Francios,

You could try something like this.

1. Go to DOS prompt
2. go to the root of D:
3. type : tree>C:\cdtree.txt
4. exit DOS
5. Open C:\cdtree.txt in notepad or something
6. Copy & Paste into the memo box in access.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:16
Joined
Feb 28, 2001
Messages
27,223
First, look up the help topic "FileSearch" to familiarize yourself with it.

Now, understand that you have VERY limited formatting ability. Essentially, within a memo field, all you have is the ASCII character set (in practical terms).

OK, in summary...

1. Set up your form to contain a button that you can click besides the text box for the memo field.
2. In the Button_Click routine, include code to do a file search for the wildcarded file name * and file type * (Or msoAllFileTypes) and file path is \ and file device is your CD-ROM drive name. I'll assume D but you make it whatever is correct for your system.
3. Set up a new search on D:\*.* (for all file types).
4. There is a collection called ".FoundFiles" that you can step through in order to find the file specification. Value .FoundFiles.Count tells you how many files. .FoundFiles(n) is the name of each file, where n ranges from 1 to the count indicated in the collection.
5. Append each new entry to your list.

The trick is, of course, that you would have to build recursive code to search each directory that you find when you searched D:\*.* (i.e. all directories located in the root of the drive.) Then for each directory in those directories, etc. etc. It is doable, but you might have to build something truly recursive to retain each filesearch context.


Now, having said this, I would NEVER do this to a poor little Memo box. I would build the filesearch, but each file would go into a table like this:

tblFilesFound
-- FileNumber (autonumber or generated by code per-drive)
-- DriveName: (Might be DriveLetter if no networking is involved)
-- ParentPath (parent path of \ is drivename:, parent of first level directory named Windows is \, parent of subdirectory Win32 is \Windows\, parent of file in Win32 subdirectory is \Windows\Win32\, etc...)
-- FileName (name.type)
-- Depth (For the root directory of the drive, depth is 0. For directories in the root, depth is 1. For subdirectories of root, depth is 2, etc.)
-- DirFlag (can be derived from the file's properties, read up on other things that FileSearch will tell you).

Prime key can be either FileNumber by itself or the combination of FileNumber and DriveName.

Now, here is where things could get kinky...

If you are building a list of all files on your CD-ROMs, and you have more than one CD-ROM, you can add a text box on your form and make a separate key for ROM name. Then you can add a CD-ROM number field to the files-found table and do reports of files broken out by disk name, then by parent path and name.
 

Users who are viewing this thread

Top Bottom