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

Не удаляется файл при поиске   Найти похожие ветки 

 
Skif   (2003-07-23 06:02) [0]

Доброе время суток всем. Вопрос в следующем - есть процедура

procedure TfmMain.GetFileSize2(FileName: string);
var
SRec: TSearchRec;
begin
FindFirst(FileName, faAnyFile, SRec);
if SRec.Size = 0 then DeleteFile(SRec.Name);
while FindNext(SRec) = 0 do
if SRec.Size = 0 then DeleteFile(SRec.Name);
FindClose(SRec);
end;


Нулевые файлы она находит, но не УДАЛЯЕТ!!! Вопрос почему?


 
Bosh ©   (2003-07-23 06:24) [1]

а ты проверь что возращает DeleteFile, если ошибку по
GetLastError и погляди что там


 
andrey_pst ©   (2003-07-23 06:54) [2]

// попробуй так:
procedure TfmMain.GetFileSize2(FileName: string);
var
SRec: TSearchRec;
begin
FindFirst(FileName, faAnyFile, SRec);
if SRec.Size = 0 then
begin
if (SRec.Attr and faArchive) = faArchive then
FileSetAttr(SRec.Name, faArchive);
DeleteFile(SRec.Name);
end;
while FindNext(SRec) = 0 do
begin
if SRec.Size = 0 then
if (SRec.Attr and faArchive) = faArchive then
FileSetAttr(SRec.Name, faArchive);
DeleteFile(SRec.Name);
end;
FindClose(SRec);
end;


 
Skif   (2003-07-23 14:19) [3]

Прошу прощения. Как говориться, все генниальное просто. Нужно было просто "DeleteFile(путь к файлу + SRec.Name);"



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

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



Память: 0.45 MB
Время: 0.011 c
3-20404
Alex_x
2003-07-16 10:12
2003.08.07
---|Ветка была без названия|---


1-20535
Evg12
2003-07-26 16:00
2003.08.07
Форма с автосайзом


1-20623
VD602
2003-07-24 22:50
2003.08.07
FileStream.WriteBiffer(SomeString, Length(SomeString));


1-20513
elf
2003-07-25 18:12
2003.08.07
Как получить Name и Caption компонента на котором находится мышь


1-20500
Alex-21
2003-07-23 21:25
2003.08.07
?????? & c_1252.nls




   Наверх