Jurgen Welz
jwelz at hotmail.com
Sun Oct 19 13:16:14 CDT 2008
If you've added a file or files to the created subfolder and opened any of the files, then you will be unable to remove the folder while they are open. Since you say you've placed an empty mdb file in the folder, you may have done so by file copy or by the createdatabase function. The 2nd approach would probably involve a reference to an mdb object. If that reference is not properly released, the file system will respond with the error you've described and will allow deletion only after closing your application. That might explain why it works after you restart your application. You need to be careful working with deleting folders because users have a way of dropping other files and folders in them. A recursive deltree removal function is something I use when moving files or synchronizing files between servers. You should probably check for any unexpected files or folders before attempting to remove a directorry. My application builds an analog of the database structure in the file system.. The system creates folders for each type of record (tabledef) when a 'cmdDocuments' command button is clicked from a record. The file structure is based on table name and a unique record identifier. In most cases the identifier is the primary key, but the users have mandated that they be able to search the file system by person, project or company name as well as project number. I hate when they mess with the files because I've had to find folders that they've accidentally dragged below other folders whenever they get into Windows Explorer with their mice. It's especially bad when we get mouse lag in terminal server or VPN sessions. I've had instances where all the estimate files for a years worth of estimates for an office were moved beneath a different year (Project Number path has a 2 character prefix for the year) resulting in a panic when over 50,000 files were lost with an errant drag. I found them in two minutes when notified, but this kind of issue makes me want to keep users out of that part of the file system permanently. That way I could simply use the PK as a path element. Oh well... Beneath that basic structure, the application provides folders for change records, invoices, pictures and other standard kinds of files related to the type of record. If a person navigates to a record and clicks the 'cmdDocuments' button, the system runs an algorithm that determines whether the folder exists and creates the folder if it doesn't. If it does exist, it displays the files and folders in a list box. Form the list container Documents form, there is a combo that allows a user to pick a document type to create. When a type is chosen, the list is filtered and the option to create new files is enabled. If a user simply needed to see if there were related documents, then there would be no need for the folder to remain in existence if none pre-existed. In that casse, upon closing the Documents form for the record, the application determines that the particular record's folder is empty and the folder is removed. Perhaps I could have deferred the folder creation until the user actually wishes to create a file, but I also allow the option for a user to pop an explorer window for the record to drop in something like a scanned document or other externally generated document or email, it was expedient to immediately create the folder and populate the listboox with no files rather than run different code that didn't populate the list. When a user creates an Invoice, an approprate invoice subfolder is created and the document created in locus. Ciao Jürgen Welz Edmonton, Alberta jwelz at hotmail.com > Date: Sun, 19 Oct 2008 09:32:46 -0700 > From: iggy at nanaimo.ark.com > To: accessd at databaseadvisors.com > Subject: Re: [AccessD] Creating Subdirectories > > Hey Jurgen > Thanks again I will try it. Maybe in my looping and checking and putting > the path back together I am picking up some spaces. But kind of still > wondering why it works on the second try. > Anyway back to it. _________________________________________________________________