Solved

Delete a directory - Access 97

Posted on 2001-06-18
13
208 Views
Last Modified: 2008-02-26
Hi all,

1 of my procedures creates a temp directory (c:\TempImportDb) in which I put a copy of empty tables, import some data, and do some stuff. At the end I want to delete the temp database (kill statement which works fine) and then delete the temp directory (RmDir which does not work at all). I do:

     Dim dbPathDir As String
     dbPathDir = "C:\TempImportDb\"

     If fIsFileDIR("C:\TempImportDb\", vbDirectory) = True Then
              RmDir dbPathDir
     End If

I am getting error 75, "Path/File access error". Seems like access thinks that the file is still being used. I also tried the ChDir command befor the RmDir but no joy. Any ideas?

Any advice would be appreciated

Dave
0
Comment
Question by:dcobau
  • 3
  • 2
  • 2
  • +2
13 Comments
 
LVL 5

Expert Comment

by:gbaren
Comment Utility
Try ChDir to another directory before deleting it.
0
 
LVL 6

Expert Comment

by:cjswimmer
Comment Utility
If there are any files left in the directory, the kill statement will fail.  If you are opening an Access db file in that dir, it creates an ldb file while it is open.  The ldb file might not be deleted by the time you try to kill the dir.  Try testing for dir(C:\TempImportDb\*.*) in a loop and use a Kill function for everything it finds until the Dir returns "".  You might want to trap for errors too in case Access is still closing and you can't delete the ldb file.  hope this helps.

cjswimmer
0
 
LVL 2

Expert Comment

by:jack49a
Comment Utility
Add a reference to Microsoft Scripting Runtime library and delete using the FileSystemObject. You can also use the FileSystemObject to move or delete files.  I use it with Access 2000,  Don't think it works with 97 though.

Jack

For example

Sub TempFolder()
Dim objFS As New Scripting.FileSystemObject
Dim strFolder As String

strFolder = "C:\TempImportDb\"

If objFS.FolderExists(strFolder) Then
  objFS.DeleteFolder (strFolder)
   MsgBox "Folder " & strFolder & " deleted"
   Else
   MsgBox "Folder " & strFolder & " does not exist"
 End If


Set objFS = Nothing
End Sub
0
 
LVL 2

Expert Comment

by:jack49a
Comment Utility
According to  'VB and VBA in a Nutshell' this FileSystemObject.DeleteFolder method will delete folders and contents (files and subdirectories). (Permanent delete not recycle bin)  Can set option to force it to delete read only files if needed.
Jack
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:dcobau
Comment Utility
Well, thanks everybody for your comments. I have resolved my problem by deleting the directory (if it exhist)from another db. db1 opens db2 where I create the temp dir and where I wanted to delete it after doing things. Now I check and delete it from db1 before opening db2.

Thanks again

Dave
0
 
LVL 6

Expert Comment

by:cjswimmer
Comment Utility
If the problem is resolved then you need to either delete the question if you discovered the solution completely on your own or award the points to one of the experts.  Did any of the posts in this thread contribute to your solution?  
0
 

Author Comment

by:dcobau
Comment Utility
hi ciswimmer,

I worked out a solution by myself, so I guess I need to delete the question. How do I do that?

Dave
0
 
LVL 6

Expert Comment

by:cjswimmer
Comment Utility
It looks like you've got 6 other questions that are in some sort of limbo from the past year or so.  You should revisit those questions and either delete them if the problem was never solved, continue the discussion, or award the points to the closest solution.  Experts who examine a question owner's profile may be less likely to participate in offering a solution if they see that you do not follow through on finishing the session.  Just a suggestion.

cjswimmer
0
 

Accepted Solution

by:
ComTech earned 0 total points
Comment Utility
Question will be placed in PAQ.

ComTech
CS Admin @ EE
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now