Download Now

    Reference TShellFileOperation

    Declared in Codebot.Windows.Shell.Tools.pas on line 44

    TShellFileOperation copies, moves, renames, deletes, and creates files and folders using Windows, which shows its progress dialog, asks about conflicts, and records operations so they can be undone in Windows Explorer. Operations are added and then performed together by Execute, or performed at once by Copy, Move, Rename, Delete, and NewFolder. Paths are file system paths, shell parsing names, or known folders such as shell:Downloads
      TShellFileOperation = class(TComponent)
      public
        { Create a new shell file operation }
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        { Remove the operations added }
        procedure Clear;
        { Add copying a file or folder into a folder, optionally with a new name }
        procedure AddCopy(const Source, Folder: string; const NewName: string = '');
        { Add moving a file or folder into a folder, optionally with a new name }
        procedure AddMove(const Source, Folder: string; const NewName: string = '');
        { Add renaming a file or folder }
        procedure AddRename(const Source, NewName: string);
        { Add deleting a file or folder. With the foAllowUndo option it is moved to
          the recycle bin }
        procedure AddDelete(const Source: string);
        { Add creating a folder inside a folder }
        procedure AddNewFolder(const Folder, Name: string);
        { Add creating an empty file inside a folder }
        procedure AddNewFile(const Folder, Name: string);
        { Perform the operations added and then remove them. Returns false if the
          user cancelled or an operation failed. Raises an exception if a path is
          not found }
        function Execute: Boolean;
        { Copy files or folders into a folder }
        function Copy(const Source, Folder: string): Boolean; overload;
        function Copy(Source: TStrings; const Folder: string): Boolean; overload;
        { Move files or folders into a folder }
        function Move(const Source, Folder: string): Boolean; overload;
        function Move(Source: TStrings; const Folder: string): Boolean; overload;
        { Rename a file or folder }
        function Rename(const Source, NewName: string): Boolean;
        { Delete files or folders }
        function Delete(const Source: string): Boolean; overload;
        function Delete(Source: TStrings): Boolean; overload;
        { Create a folder inside a folder }
        function NewFolder(const Folder, Name: string): Boolean;
        { The user cancelled an operation during the last Execute }
        property Aborted: Boolean read FAborted;
        { The number of operations added }
        property Count: Integer read GetCount;
      published
        { The options of the operations }
        property Options: TShellFileOptions read FOptions write FOptions default [foAllowUndo];
      end;

    See also