Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

Deleting directory contents Find similar branches


Марина   (2001-12-20 15:42) [0]

Подскажите, пожалуйста, как удалить содержимое каталога,а сам каталог оставить? Нужно что-то вроде deletefile("c:\kio\massiv\*.*")Заранее благодарна и прошу прощения за "чайниковский" вопрос.



gek   (2001-12-20 15:47) [1]

if Findfirst("\TEMP\*.tmp",faAnyFile, SearchRec)= 0 then
while (FindNext(SearchRec) = 0) do
if not deletefile(pchar("\TEMP\"+SearchRec.name))then
Application.Terminate;
FindClose (SearchRec);



Dimka Maslov   (2001-12-20 16:05) [2]

uses Windows, SysUtils, Classes, Masks;

procedure DeleteFiles(Path: string);
var
Mask: string;
SearchRec: TSearchRec;
FindResult: Integer;
List: TStringList;
i: Integer;
begin
Mask:=ExtractFileName(Path);
if Mask = "" then Mask:="*.*";
Path:=ExtractFilePath(Path);
if Path = "" then Path:=IncludeTrailingBackslash(GetCurrentDir);
List:=TStringList.Create;
try
FindResult:=FindFirst(Path+"*.*", faAnyFile, SearchRec);
try
while FindResult = 0 do with SearchRec do begin
if ((Attr and faDirectory) = 0) and MatchesMask(Name, Mask) then
List.Add(Name);
FindResult:=FindNext(SearchRec);
end;
for i:=0 to List.Count - 1 do DeleteFile(Path+List[i]);
finally
FindClose(SearchRec);
end;
finally
List.Free;
end;
end;



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top















Memory: 0.82 MB
Time: 0.037 c
1-22188
based on
2001-12-14 13:09
2002.01.08
How to read a large file ???


1-22133
Sand worm
2001-12-19 14:55
2002.01.08
Frame


7-22438
Sasha
2001-08-17 16:14
2002.01.08
Voice modem


1-22065
Victor
2001-12-19 07:30
2002.01.08
about webbrowser


14-22336
Ivan Shikhalev
2001-11-02 23:31
2002.01.08
Golden banana





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish