Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.11.13;
Скачать: CL | DM;

Вниз

Как удалить директорию с фалами?   Найти похожие ветки 

 
Turonix   (2003-10-31 13:41) [0]

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


 
Sandman25 ©   (2003-10-31 13:42) [1]

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


 
VAleksey ©   (2003-10-31 13:46) [2]

см функцию
shFileOperation


 
WithOut Any ... ©   (2003-10-31 13:49) [3]

deltree.exe с соответствуюшими ключами?


 
Amoeba   (2003-10-31 15:51) [4]

Читай http://www.delphikingdom.com/mastering/fileshellapi.htm
Там все написано.


 
WithOut Any ... ©   (2003-10-31 16:36) [5]

Можно попробовать так:
Function MyRemoveDir(sDir : String) : Boolean;
var
iIndex : Integer;
SearchRec : TSearchRec;
sFileName : String;
begin
Result := False;
sDir := sDir + "\*.*";
iIndex := FindFirst(sDir, faAnyFile, SearchRec);

while iIndex = 0 do begin
sFileName := ExtractFileDir(sDir)+"\"+SearchRec.Name;

if SearchRec.Attr = faDirectory then begin
if (SearchRec.Name <> "" ) and
(SearchRec.Name <> ".") and
(SearchRec.Name <> "..") then
MyRemoveDir(sFileName);
end else begin
if SearchRec.Attr <> faArchive then
FileSetAttr(sFileName, faArchive);
if NOT DeleteFile(sFileName) then
ShowMessage("Could NOT delete " + sFileName);
end;
iIndex := FindNext(SearchRec);
end;

FindClose(SearchRec);

RemoveDir(ExtractFileDir(sDir));
Result := True;
end;

Example:

if NOT MyRemoveDir("D:\myDir") then
ShowMessage("Can NOT delete dir");

Note:
(1) Any system/hidden/read-only files will be deleted.


 
Amoeba   (2003-10-31 16:50) [6]

Ну зачем же изобретать плохой велосипед и городить огород? Все легко делается ф-ей shFileOperation. Еще раз повторяю: читай статью http://www.delphikingdom.com/mastering/fileshellapi.htm

WithOut Any ... © (31.10.03 16:36) [5]
Не пачкай человеку мозги!



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

Текущий архив: 2003.11.13;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.026 c
1-41391
dn
2003-10-26 21:18
2003.11.13
TStringGrid и ASCII


14-41941
Style
2003-10-20 15:12
2003.11.13
certifications.ru


1-41416
Vadim S
2003-10-29 16:15
2003.11.13
Invalid pointer operation


4-42244
Jack
2003-09-16 14:00
2003.11.13
ReadDitectoryChangeW


3-41018
Stas
2003-10-24 15:43
2003.11.13
Таблицы и представления