이넘을 대체 어디서 들고 왔더라 ... 분명히 외국 사이트에서 퍼왔을
텐데... ㅠㅠa;; ( 나이가 나이다 보니 )
Function File_DirOperations_Datail(
Action : String; {COPY, DELETE, MOVE, RENAME}
RenameOnCollision : Boolean; {Renames if directory exists}
NoConfirmation : Boolean; {Responds "Yes to All" to any dialogs}
Silent : Boolean; {No progress dialog is shown}
ShowProgress : Boolean; {displays progress dialog but no file
names}
FromDir : String; {From directory}
ToDir : String {To directory}
): Boolean;
var
SHFileOpStruct : TSHFileOpStruct;
FromBuf, ToBuf: Array [0..255] of Char;
begin
Try
If Not DirectoryExists(FromDir) Then
Begin
Result := False;
Exit;
End;
Fillchar(SHFileOpStruct, Sizeof(SHFileOpStruct), 0 );
FillChar(FromBuf, Sizeof(FromBuf), 0 );
FillChar(ToBuf, Sizeof(ToBuf), 0 );
StrPCopy(FromBuf, FromDir);
StrPCopy(ToBuf, ToDir);
With SHFileOpStruct Do
Begin
Wnd := 0;
If UpperCase(Action) = 'COPY' Then wFunc := FO_COPY;
If UpperCase(Action) = 'DELETE' Then wFunc := FO_DELETE;
If UpperCase(Action) = 'MOVE' Then wFunc := FO_MOVE;
If UpperCase(Action) = 'RENAME' Then wFunc := FO_RENAME;
pFrom := @FromBuf;
pTo := @ToBuf;
fFlags := FOF_ALLOWUNDO;
If RenameOnCollision Then fFlags := fFlags or FOF_RENAMEONCOLLISION;
If NoConfirmation Then fFlags := fFlags or FOF_NOCONFIRMATION;
If Silent Then fFlags := fFlags or FOF_SILENT;
If ShowProgress Then fFlags := fFlags or FOF_SIMPLEPROGRESS;
End;
Result := (SHFileOperation(SHFileOpStruct) = 0);
Except
Result := False;
End;
end;
요렇게 사용합니다.
Function DelTree( DirectoryName : String ) : Boolean;
begin
Result := File_DirOperations_Datail(
'DELETE',
False,
True,
True,
False,
DirectoryName,
'' );
end;
|