DickG

DirRemove() does not delete parent folder

5 posts in this topic

Local $ThisFunc = "Delete"
$CurDir = @WorkingDir
$Ask = MsgBox(3, $ThisFunc, "Delete " & $CurDir & "?")
If $Ask = 6 Then DirRemove($CurDir & "\", 1)

This code deletes all files and subfolders under the parent, but leaves the parent folder.

Running AutoIt v3.3.14.2 on WinXP SP3.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

C:\>md test
C:\>cd test
C:\test>rmdir .
Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.
C:\test>cd ..
C:\>rmdir test
C:\>

You cannot delete the current directory

Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Does this mean that DirRemove() leaves the empty folder? The Help file says "Deletes a directory/folder." I didn't see anything that says it doesn't delete the specified folder. Now I'm confused. How do I delete the empty folder? Do I have to go to the folder's parent to delete it?

Share this post


Link to post
Share on other sites

This means that you are not able to delete a directory when a program has a file open or the has the directory set as its WorkingDirectory.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

OK, thanks. I found my problem. I didn't realize that @WorkingDir referred to the selected folder's parent.

If I select a file in a file manager (I use DOpus), then read $CMDLINERAW, it shows that folder's parent, rather than the selected folder (like I expected). Once I realized that, I was able to fix my code to handle that.

Thanks for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now