Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 팁&트릭
Delphi Programming Tip&Tricks
[91] [delphi] Shell file 을 이용한 Copy, Move, Delete, Rename - 서브 디렉토리 포함
박정모 [] 5573 읽음    2001-12-08 01:19

이넘을 대체 어디서 들고 왔더라 ... 분명히 외국 사이트에서 퍼왔을
텐데... ㅠㅠ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;



+ -

관련 글 리스트
91 [delphi] Shell file 을 이용한 Copy, Move, Delete, Rename - 서브 디렉토리 포함 박정모 5573 2001/12/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.