文件函数
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Edit2: TEdit;
Button3: TButton;
Edit3: TEdit;
Button4: TButton;
Edit4: TEdit;
Button5: TButton;
Edit5: TEdit;
Button6: TButton;
Edit6: TEdit;
Button7: TButton;
Edit7: TEdit;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then
begin
edit1.Text:=opendialog1.FileName;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//将当前路径名与指定文件名合成一个绝对的文件名
edit2.Text:=expandfilename(edit1.text)
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
//获取一个以UNC格式的包括风络驱动器名的绝对文件名
edit3.Text:=expandUNCfileName(edit1.text);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
//从绝对文件名中获取目录名
edit4.Text:=ExtractFileDir(edit1.text);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
//从绝对文件名中获取驱动器名
edit5.Text:=extractfiledrive(edit1.text);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
//从绝对文件名中获取扩展名
edit6.Text:=extractfileext(edit1.text);
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
//从绝对文件名中获取文件名
edit7.Text:=extractfilename(edit1.text);
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
//从绝对文件名中获取路径名
edit8.Text:=extractfilepath(edit1.text);
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
//从绝对文件名中获取相对于某一路径的相对路径名
edit9.Text:=extractRelativepath(edit1.text,edit4.text);
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
// 将长文件名转化为短文件名
edit10.Text:=extractshortpathname(edit1.text);
end;
end.