Вниз
Скачать: CL | DM;

Удаление папки   Найти похожие ветки 

← →
Funnymind   (2004-05-06 05:17) [0]

Как насильно удалить папку со всеми вложенными в нее файлами.
Буду благодарен за множество вариантов...


← →
miwa ©   (2004-05-06 05:25) [1]

1. SHFileOperation + F1
2. FindFirst+FindNext+FindClose+DeleteFile + F1


← →
Delphin ©   (2004-05-06 11:54) [2]

Сначало удаляешь всё сожержимое из папки, а потом и саму папку, необходимые
команды тебе написал miwa ©   (06.05.04 05:25) [1]


← →
Романов Р.В. ©   (2004-05-06 12:00) [3]


> Сначало удаляешь всё сожержимое из папки

SHFileOperation удаляет все сразу вместе с содержимым.


← →
uuuh   (2004-05-06 12:17) [4]

Предлагаю старый девовский способ удалить рекурсивно все содержимое а потом и саму папку.


← →
DVM ©   (2004-05-06 12:22) [5]

function DeleteDirectory(const Path: string): boolean;
var
 FD : TWin32FindData;
 FH : THandle;
 PartialResult:Boolean;
 LPath:string;
begin
 Result := true;
 if Path="" then exit;
 if not(DirExists(Path)) then exit;
 LPath:=Path;
 FH := FindFirstFile( PChar( Path + "*.*" ), FD );
 repeat
   PartialResult := True;
   if (FH<>INVALID_HANDLE_VALUE) and (FD.cFileName <> string(".")) and
                                              (FD.cFileName<>string("..")) then
     if (FILE_ATTRIBUTE_DIRECTORY and FD.dwFileAttributes) <> 0 then
       PartialResult := DeleteDirectory(Path + FD.cFileName + "\")
     else
       if PartialResult then
             begin
               PartialResult := SetFileAttributes(PChar(Path + FD.cFileName),
                                                        FILE_ATTRIBUTE_NORMAL);
               if PartialResult then PartialResult := DeleteFile(Path + FD.cFileName);
             end;
   if not PartialResult then
     begin
       Result := False;
       Break;
     end;
 until FindNextFile(FH,FD) = false;
 FindClose(FH);
 if Result then
 begin
   Result := SetFileAttributes(PChar(LPath), FILE_ATTRIBUTE_NORMAL);
   if Result then
   begin
     {$IOCHECKS OFF}
     RmDir(LPath);
     {$IFDEF IOCHECKS_ON}
     {$IOCHECKS ON}
     {$ENDIF IOCHECKS_ON}
     Result := IOResult = 0;
   end;
 end;
end;



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.039 c
6-1081178101
electric
2004-04-05 19:15
2004.05.23
FTP.FTPDirectoryList.name


3-1083152021
КоммофОнСамый
2004-04-28 15:33
2004.05.23
помогите Найти пример к Employee.gdb


4-1080651544
BorH
2004-03-30 16:59
2004.05.23
Список Uninstall


1-1083736941
Dogless
2004-05-05 10:02
2004.05.23
Передача TNotifyEvent в качестве константы


14-1083679000
yevgeniy
2004-05-04 17:56
2004.05.23
Прямо неудобно спрашивать... но: как устанавливать компоненты?




   Наверх