Hi,
I am unable to delete a subfolder that I have created programatically.
I am using a modification of the apiSHFileOperation by Dev Ashish
(http://www.mvps.org/access/api/api0026.htm) to copy the files.
A File Copy function is called as part of a loop to copy a series of
files from a variety of locations that are stored in the database. All
the files are copied to a folder specified by the user. Once the user
has used this folder (to write a CD of the files) he is supposed to be
able to delete it. However, for as long as Access remains open, it keeps
a handle on this directory it has created, preventing Windows from
deleting the folder. The files within the folder can be deleted, but not
the folder itself.
This is a bit of an inconvenience, but mostly I am not too keen on using
code that I don't comprehend. Can anyone point me to how to make Access
release the folder? Perhaps I am not terminating the operation correctly?
Thanks in advance
Eike
Bits of code below:
##this is within the main Sub, it retrieves the recordset, then calls
the file copy function for each item;
With rsSelected
.MoveFirst
Do While Not .EOF
If fCopyAToB(!FileName, txtCopyFolder) <> True Then
MsgBox "Abandoning File Copy Process" & vbNewLine & "There was
an error writing....", vbOKOnly & vbCritical, AppnName
GoTo Leave_Sub
End If
.Edit
![CD-id] = txtCDID
!Temp = False
.Update
.Bookmark = .LastModified
.MoveNext
Loop
End With
##Here is the functional bit of the apiSHFileOperation;
Function fCopyAToB(strA As String, strB As String)As Long
....
With tshFileOp
.pFrom = strA & vbNullChar
.pTo = strB & vbNullChar
.fFlags = FOF_NOCONFIRMMKDIR + FOF_NOCONFIRMATION
End With
lngRet = apiSHFileOperation(tshFileOp)
fCopyAToB = (lngRet = 0)
End Function