Borrar directorios con Delphi
Hola,
No consigo borrar directorios vacÃos con delphi (4), si utilizo rmDir se produce 'I/O Error 32', tampoco me funciona RemoveDir.
Estoy trabajando en windows 2000.
Gracias
No consigo borrar directorios vacÃos con delphi (4), si utilizo rmDir se produce 'I/O Error 32', tampoco me funciona RemoveDir.
Estoy trabajando en windows 2000.
Gracias
BORRAR UN DIRECTORIO Y TODOS SUS FICHEROS
procedure TForm1.Button1Click(Sender: TObject);
var
DirInfo: TSearchRec;
r : Integer;
begin
r := FindFirst('C:DownloadTest*.*', FaAnyfile, DirInfo);
while r = 0 do begin
if ((DirInfo.Attr and FaDirectory <> FaDirectory) and
(DirInfo.Attr and FaVolumeId <> FaVolumeID)) then
if DeleteFile(pChar('C:Downloadtest\' + DirInfo.Name))
= false then
{Si no puede borrar el fichero}
ShowMessage('Unable to delete : C:Downloadtest\' +
DirInfo.Name);
r := FindNext(DirInfo);
end;
SysUtils.FindClose(DirInfo);
if RemoveDirectory('C:DownloadTest') = false then
{Si no puedes borrar el directorio}
ShowMessage('Unable to delete dirctory : C:Downloadtest');
end;
borrarÃa la carpeta test y los archivos que contiene, pero no si tiene sub carpetas (darÃa error al no poder eliminar las subcarpetas)
procedure TForm1.Button1Click(Sender: TObject);
var
DirInfo: TSearchRec;
r : Integer;
begin
r := FindFirst('C:DownloadTest*.*', FaAnyfile, DirInfo);
while r = 0 do begin
if ((DirInfo.Attr and FaDirectory <> FaDirectory) and
(DirInfo.Attr and FaVolumeId <> FaVolumeID)) then
if DeleteFile(pChar('C:Downloadtest\' + DirInfo.Name))
= false then
{Si no puede borrar el fichero}
ShowMessage('Unable to delete : C:Downloadtest\' +
DirInfo.Name);
r := FindNext(DirInfo);
end;
SysUtils.FindClose(DirInfo);
if RemoveDirectory('C:DownloadTest') = false then
{Si no puedes borrar el directorio}
ShowMessage('Unable to delete dirctory : C:Downloadtest');
end;
borrarÃa la carpeta test y los archivos que contiene, pero no si tiene sub carpetas (darÃa error al no poder eliminar las subcarpetas)
