📄 unit1.pas.~15~
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Borland.Vcl.FileCtrl, Borland.Vcl.StdCtrls, System.ComponentModel,
Borland.Vcl.Menus,unit2,System.Text;
type
TForm3 = class(TForm)
FileListBox1: TFileListBox;
DirectoryListBox1: TDirectoryListBox;
DriveComboBox1: TDriveComboBox;
MainMenu1: TMainMenu;
F1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
E1: TMenuItem;
jianqie1: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
procedure N11Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure jianqie1Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure FormCrete(Sender: TObject);
procedure DriveComboBox1Change(Sender: TObject);
procedure DirectoryListBox1Change(Sender: TObject);
procedure Copy(sName:string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.nfm}
var
str:string;
procedure TForm3.DirectoryListBox1Change(Sender: TObject);
begin
FileListBox1.Directory :=DirectoryListbox1.Directory ;
Form3.Caption :=DirectoryListBox1.Directory;
end;
procedure TForm3.DriveComboBox1Change(Sender: TObject);
begin
DirectoryListbox1.Drive :=DriveComboBox1.Drive ;
end;
procedure TForm3.FormCrete(Sender: TObject);
begin
Form3.Caption :=DirectoryListBox1.Directory;
end;
//属性
procedure TForm3.N2Click(Sender: TObject);
var
att:word;
begin
Form2.Label2.Caption :=FileListBox1.Items [FileListBox1.ItemIndex ];
Form2.Label3.Caption :=FileListBox1.Directory ;
Form2.Label4.Caption :=DateTimeTOStr(FileDateToDateTime(FileAge(FileListBox1.FileName)));
att:= FileGetAttr(Form2.Label2.Caption);
Form2.CheckBox1.Checked :=(att and faReadOnly)=faReadOnly;
Form2.CheckBox2.Checked :=(att and faHidden)=faHidden;
Form2.ShowModal;
end;
//退出
procedure TForm3.N4Click(Sender: TObject);
begin
Close;
end;
//新建文件
procedure TForm3.N5Click(Sender: TObject);
var
fName:string;
begin
fName:= Dialogs.InputBox('新建文件','请输入文件名称','') ;
if fName<>'' then
begin
fName:=DirectoryListBox1.Directory +'\'+ fName ;
FileCreate(fName);
if IOResult<>0 then
MessageDlg('Can not Create '+ fName,mtWarning,[mbOk],0);
FileListBox1.Update;
end;
end;
//新建文件夹
procedure TForm3.N6Click(Sender: TObject);
var
dir:string;
begin
dir:=Dialogs.InputBox('新建文件夹','请输入文件夹名称','') ;
if dir<>'' then
dir:=ExpandFileName(dir);
MkDir(dir);
if IOResult<>0 then
MessageDlg('Can not Create directory',mtWarning,[mbOk],0);
DirectoryListBox1.Update ;
end;
//剪切
procedure TForm3.jianqie1Click(Sender: TObject);
begin
N7Click(Sender);
DeleteFile(FileListBox1.FileName);
end;
//复制
procedure TForm3.N7Click(Sender: TObject);
var
a:System.Text.StringBuilder;
begin
a:= System.Text.StringBuilder.Create(255) ;
GetTempPath(255,a);
str:=a.ToString;
a.Free;
if FileListBox1.FileName <>'' then
Copy(FileListBox1.Items [FileListBox1.ItemIndex ]);
end;
//复制文件
procedure TForm3.Copy(sName:string);
var
s,t:TFileStream;
begin
s:=TFileStream.Create(sName,fmOpenRead);
try
SetCurrentDir(str);
t:=TFileStream.Create(sName,fmOpenWrite or fmCreate) ;
try
t.CopyFrom(s,s.Size);
finally
t.Free ;
end;
finally
s.Free ;
end;
end;
// 粘贴
procedure TForm3.N8Click(Sender: TObject);
begin
N7Click(Sender);
end;
//删除
procedure TForm3.N9Click(Sender: TObject);
begin
if FileListBox1.Focused then
begin
if FileListBox1.FileName<>'' then
begin
if MessageDlg('确定要删除'+FileListBox1.Items [FileListBox1.ItemIndex ]+'吗?',mtInformation,[mbYes,mbNo],0)=mrYes then
DeleteFile(FileListBox1.FileName);
FileListBox1.Update ;
end;
end;
if DirectoryListBox1.Focused then
begin
if DirectoryListBox1.Directory<>'' then
begin
if MessageDlg('确定要删除'+DirectoryListBox1.Items[DirectoryListBox1.ItemIndex ]+'吗?',mtInformation,[mbYes,mbNo],0)=mrYes then
RemoveDir(DirectoryListBox1.Directory);
DirectoryListBox1.Update ;
end;
end;
end;
procedure TForm3.N11Click(Sender: TObject);
var
newName:string;
begin
if DirectoryListBox1.Focused then
begin
newName:=Dialogs.InputBox('重命名文件夹','请输入新的文件夹名称','') ;
if newName<>'' then
RenameFile(DirectoryListBox1.Items[DirectoryListBox1.ItemIndex],newName);
DirectoryListBox1.Update ;
end;
if FileListBox1.Focused then
begin
newName:=Dialogs.InputBox('重命名文件','请输入新的文件名','') ;
if newName<>'' then
RenameFile(FileListBox1.Items [FileListBox1.ItemIndex ],newName);
FileListBox1.Update ;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -