Dear Sirs;
I hope to find all of you in good health.
Could you help me to delete a folder and its contents?
Regards;
AHMED NADY
- Thomas Linder Puls
- VIP Member
- Posts: 1411
- Joined: 28 Feb 2000 0:01
If you mean remove from the project but keep the files on the disk then select the folder in the project tree (in the IDE) and press the DEL key.
If you mean really delete the folder from the disk you can open the folder in an explorer (can be done from the project tree right clicking on the folder and select Explore...) and then deleting it there (also using the DEL key).
If you mean really delete the folder from the disk you can open the folder in an explorer (can be done from the project tree right clicking on the folder and select Explore...) and then deleting it there (also using the DEL key).
Regards Thomas Linder Puls
PDC
PDC
Dear Sir;
Thank you for your reply.
I mean Delete that delete the folder from the disk.
I want to create a predicate to delete a selected folder to be deleted with its contents.
When I try this, error appears telling me that the folder has contents.
Therefore, I want to delete the folder with its contents whatever.
Regards;
Eng. Ahmed Nady
Thank you for your reply.
I mean Delete that delete the folder from the disk.
I want to create a predicate to delete a selected folder to be deleted with its contents.
When I try this, error appears telling me that the folder has contents.
Therefore, I want to delete the folder with its contents whatever.
Regards;
Eng. Ahmed Nady
Hi.
Just remove subfolder by subfolder, file by file.
Do not forget catch errors according your needs.
Just remove subfolder by subfolder, file by file.
Code: Select all
class predicates
deleteFolder : (string Folder).
clauses
deleteFolder(Folder) :-
foreach SubFolder = directory::getSubDirectories_nd(Folder) do
deleteFolder(SubFolder)
end foreach,
directory::forAllFiles(Folder,
{(File) :-
% file::setAttributes(File, [fileSystem_api::readOnly], false),
file::delete(File)}),
directory::deleteDirectory(Folder).
- Tonton Luc
- VIP Member
- Posts: 204
- Joined: 16 Oct 2001 23:01
Hi,
Code: Select all
clauses
onTest(_Source, _MenuTag):-
mainExe::getFileName(Root,_),
if Path = directory::browseForFolder(getVpiWindow(),"Please select a folder :",Root,false) then
Stop = varM::new(0),
foreach F = directory::getFilesInDirectoryAndSub_nd(Path) do
try
file::delete(F)
catch _ do
Stop:value := 1,
succeed()
end try
end foreach,
if Stop:value = 0 then
try
directory::deleteDirectory(Path)
catch _ do
succeed()
end try
else
vpiCommonDialogs::note("Cannot delete :","this folder is not empty.")
end if
end if.
Bonjour.
It lacks subFolders deleting, looks like...
I use something like this:
If the set:isEmpty() after calling, then deleting complete, else there are files to do what it need to do with.
It lacks subFolders deleting, looks like...
I use something like this:
Code: Select all
class predicates
deleteFolder : (string Folder) -> setM{string FileName} Undeleted.
clauses
deleteFolder(Folder) = Set :-
Set = setM_redBlack::new(),
deleteFolder(Folder, Set).
class predicates
deleteFolder : (string Folder, setM{string FileName} Undeleted).
clauses
deleteFolder(Folder, Set) :-
foreach SubFolder = directory::getSubDirectories_nd(Folder) do
deleteFolder(SubFolder, Set)
end foreach,
directory::forAllFiles(Folder,
{(File) :-
try
file::delete(File)
catch _ do
Set:insert(File)
end try}),
try directory::deleteDirectory(Folder) catch _ do succeed() end try.