Access denied error ! - Page 2 - Forum

Forum Navigation
You need to log in to create posts and topics.

Access denied error !

PreviousPage 2 of 2

The reason you can't use RemoveFolder is you probably still have files in it. RemoveFolder only works on empty folders.

If you know exactly what files are there then you need to FileErase each one and then remove the folder.
If you don't know the file names or how many there are you could do something like this:

FileList "[TempDir]Test_Folder" "Files" "[tempfilelist]"
FileWrite "[TempDir]tempfilelist.txt" "All" "[tempfilelist]"
FileLen "[TempDir]tempfilelist.txt" "[tempfilelistlen]"
Loop "1" "[tempfilelistlen]" "[filelistloop]"
FileRead "[TempDir]tempfilelist.txt" "[filelistloop]" "[filename]"
FileErase "[filename]"
EndLoop
RemoveFolder "[TempDir]Test_Folder"

@jncon

Thanks for your help.

The problem of your idea is that rmdir removes only  an empty directory.

@pauljonestindall

Thanks for suggesting idea.

The only problem of your suggestion is that "FileList" generates a list of files in one line (the names of the files are continuous not in separated line). So, we can't use "FileLen" to calculate the numbers of the files.

What's your idea to solve this problem?

@saeid

The problem of your idea is that rmdir removes only an empty directory

Please read this page ... https://www.computerhope.com/rmdirhlp.htm ... on how to get around this issue.

The only problem of your suggestion is that "FileList" generates a list of files in one line (the names of the files are continuous not in separated line). So, we can't use "FileLen" to calculate the numbers of the files.

On this Help page for VisualNEOWin ... https://winhelp.visualneo.com/Files1.html ... in the section for FileList command, it says ...

Multiple files will be separated by carriage returns ([#13])

... so you can split this content into arrayed variables and loop through them.

 

Hello,

Filelist does not generates a list in one line. It makes a list with CR seperated lines.

You could parse this into an array and loop through it.

FileList "C:\Temp\*.jpg" "Files" "[flist]"
StrParse "[flist]" "[#13]" "[filist]" "[filistcount]"

Regards

Ps:Oops Gaev was faster! ;-)

 

 

This method has been tested and working:

create the cmd file with neobook automatically when open your app (startup event):

FileWrite "[PubDir]remove.cmd" "1" "waitfor /T 2 pause"
FileWrite "[PubDir]remove.cmd" "2" "rmdir /Q /S [TempDir]Test_folder"

run cmd file with Shutdown event:

Run "[PubDir]remove.cmd" "" "Hidden" "" ""

It will remove the "Test_folder" directory and it's files and subdirectories 2 s after app closed.

@gaev

@hpw

@jncon

Thanks for all of your helps.

Yes, StrParseing the FileList variable would be a faster executing code.

PreviousPage 2 of 2