PC Review


Reply
Thread Tools Rate Thread

Directory Removal

 
 
=?Utf-8?B?Q2l0eUd1eQ==?=
Guest
Posts: n/a
 
      16th May 2006
Hi,
Once again I come to you all for help.

I simply want to delete a directory. I have read over the examples
already posted on this site and used the useful info passed on to
others but I still cannot get either "RmDir" or "FileSysObj.DeleteFolder"
to remove the directory.

I have used the RmDir command before and it worked okay, but not
in this application. I am beginning to suspect that I have crossed the
line with respect to how many levels of directories the RmDir command
can handle. In my working example I have 6 levels of directories, in
my latest example I have 7 levels of directories.

Code fragments:
Dim strDirRmv as String
Dim ojbFileSysObj as Object
 
Reply With Quote
 
 
 
 
Graham Mandeno
Guest
Posts: n/a
 
      16th May 2006
I just wrote and tested the following code which creates 10 levels of
folders and then deletes them again:

Sub DirLevels()
Const cRoot = "C:"
Const cLevels = 10
Dim i As Integer
Dim sPath As String
sPath = cRoot
For i = 1 To cLevels
sPath = sPath & "\" & i
MkDir sPath
Next
MsgBox sPath & " created." & vbCrLf & "Click OK to remove."
Do
RmDir sPath
sPath = Left(sPath, InStrRev(sPath, "\") - 1)
Loop Until sPath = cRoot
End Sub

It works fine for me (WinXP Pro SP2 with NTFS disk). Try it on your
machine. If it works then the problem must be either in permissions, or
maybe another thread is accessing the folder you are trying to delete.

I have a vague recollection that folders on a FAT16 drive are limited to 8
levels, but if you can create them then you ought to be able to delete them.
Have you tried deleting the folder from Explorer?
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



"CityGuy" <(E-Mail Removed)> wrote in message
news:04AB66D2-4666-49D3-9C05-(E-Mail Removed)...
> Hi,
> Once again I come to you all for help.
>
> I simply want to delete a directory. I have read over the examples
> already posted on this site and used the useful info passed on to
> others but I still cannot get either "RmDir" or "FileSysObj.DeleteFolder"
> to remove the directory.
>
> I have used the RmDir command before and it worked okay, but not
> in this application. I am beginning to suspect that I have crossed the
> line with respect to how many levels of directories the RmDir command
> can handle. In my working example I have 6 levels of directories, in
> my latest example I have 7 levels of directories.
>
> Code fragments:
> Dim strDirRmv as String
> Dim ojbFileSysObj as Object
> .
> .
> .
> '
> 'now remove directory
> Debug.Print "H9- deleting folder"
> RmDir strDirRmv ' remove dir
>
> ' i tried rmdir 1st, had no luck so then tried filesysob, still no
> luck
> 'Set FileSysObj = CreateObject("Scripting.FileSystemObject")
> 'FileSysObj.DeleteFolder (strDirRmv)
> '
> strText01 = "Removed directory " & strKeyId
> strTxtLine = "- Removed directory ...\" & strYrMonth & strDirName
> .
> .
> .
>
>
> With RmDir I get a "Path/File access error" error message.
> With the FileSysObj command I get a "Permissions Denied" error message.
>
> Can anyone shed some light as to what is failing? Thanks alot



 
Reply With Quote
 
=?Utf-8?B?Q2l0eUd1eQ==?=
Guest
Posts: n/a
 
      16th May 2006
Hi,

What made me think there was a level problem is that the code just
before the chunk I included with my original message deletes the contents
of the directory in question. And the delete part works just fine, it is when
I try to remove the directory that I get an error. Here is a chunk of the
preceeding code:

'folder exists, see if files in it
If Len(Dir(strDirRmv & "\*.*")) > 0 Then
'
'files in directory so remove them 1st
Debug.Print "H8- deleting files in folder"
Kill strDirRmv & "\*.*" ' remove all files in dir
'
End If

I am running on Windows XP Pro, but the directory and sub-directories
reside on a network drive. You were correct in your assumption about
a thread accessing the directory to be deleted. I can't even delete it
with windows explorer. Is there way to determine what thread is
causing this error?

Thanks again for your help.


"Graham Mandeno" wrote:

> I just wrote and tested the following code which creates 10 levels of
> folders and then deletes them again:
>
> Sub DirLevels()
> Const cRoot = "C:"
> Const cLevels = 10
> Dim i As Integer
> Dim sPath As String
> sPath = cRoot
> For i = 1 To cLevels
> sPath = sPath & "\" & i
> MkDir sPath
> Next
> MsgBox sPath & " created." & vbCrLf & "Click OK to remove."
> Do
> RmDir sPath
> sPath = Left(sPath, InStrRev(sPath, "\") - 1)
> Loop Until sPath = cRoot
> End Sub
>
> It works fine for me (WinXP Pro SP2 with NTFS disk). Try it on your
> machine. If it works then the problem must be either in permissions, or
> maybe another thread is accessing the folder you are trying to delete.
>
> I have a vague recollection that folders on a FAT16 drive are limited to 8
> levels, but if you can create them then you ought to be able to delete them.
> Have you tried deleting the folder from Explorer?
> --
> Good Luck!
>
> Graham Mandeno [Access MVP]
> Auckland, New Zealand
>
>
>
> "CityGuy" <(E-Mail Removed)> wrote in message
> news:04AB66D2-4666-49D3-9C05-(E-Mail Removed)...
> > Hi,
> > Once again I come to you all for help.
> >
> > I simply want to delete a directory. I have read over the examples
> > already posted on this site and used the useful info passed on to
> > others but I still cannot get either "RmDir" or "FileSysObj.DeleteFolder"
> > to remove the directory.
> >
> > I have used the RmDir command before and it worked okay, but not
> > in this application. I am beginning to suspect that I have crossed the
> > line with respect to how many levels of directories the RmDir command
> > can handle. In my working example I have 6 levels of directories, in
> > my latest example I have 7 levels of directories.
> >
> > Code fragments:
> > Dim strDirRmv as String
> > Dim ojbFileSysObj as Object
> > .
> > .
> > .
> > '
> > 'now remove directory
> > Debug.Print "H9- deleting folder"
> > RmDir strDirRmv ' remove dir
> >
> > ' i tried rmdir 1st, had no luck so then tried filesysob, still no
> > luck
> > 'Set FileSysObj = CreateObject("Scripting.FileSystemObject")
> > 'FileSysObj.DeleteFolder (strDirRmv)
> > '
> > strText01 = "Removed directory " & strKeyId
> > strTxtLine = "- Removed directory ...\" & strYrMonth & strDirName
> > .
> > .
> > .
> >
> >
> > With RmDir I get a "Path/File access error" error message.
> > With the FileSysObj command I get a "Permissions Denied" error message.
> >
> > Can anyone shed some light as to what is failing? Thanks alot

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XP Directory Privacy Removal (NTFS) lasantiago2@gmail.com Windows XP Help 1 28th Mar 2006 07:43 PM
Removal of Active Directory xavier Microsoft Windows 2000 Active Directory 4 1st Jun 2004 04:29 PM
Removal of directory from root =?Utf-8?B?QUJT?= Windows XP Help 0 6th Feb 2004 06:41 PM
Re: Active Directory Removal Cary Shultz [A.D. MVP] Microsoft Windows 2000 Active Directory 0 11th Dec 2003 08:36 PM
Active Directory Removal?? HELP!! PLS!! WINNI Microsoft Windows 2000 Active Directory 3 29th Jul 2003 07:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 AM.