Jump to content
Fórum Script Brasil
  • 0

(Resolvido) Directorylistbox E Filelistbox


Guest --Silvia --
 Share

Question

2 answers to this question

Recommended Posts

  • 0

vai ai um exemplo que fiz para isso:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, FileCtrl;

type
  TForm1 = class(TForm)
    FileListBox1: TFileListBox;
    DirectoryListBox1: TDirectoryListBox;
    Edit1: TEdit;
    procedure FileListBox1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FileListBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var S, s1: string; tag : integer;

begin
   if key = VK_Delete then
      begin
      edit1.text := trim(FileListBox1.FileName);
      s := trim(FileListBox1.FileName);

      while Pos('\', S) > 0 do
         begin
            tag := Pos('\', S);
            S[Pos('\', S)] := '0';
         end;
      s1 := copy(s,tag+1,20);

      if FileExists(trim(edit1.text)) then
         if MessageDlg('Deseja Apagar o arquivo ' + s1 + ' ?',
            mtConfirmation, [mbYes, mbNo], 0) = mrYes then
            begin
               DeleteFile(trim(edit1.text));
               FileListBox1.Update;
               FileListBox1.Refresh;
            end
         else
            showmessage('Operação Cancelada');

      end;

end;

end.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...