⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 安装程序时或在打开数据文件时都需要打开文件夹的操作,本例提供创建和删除文件夹的操作
💻 PAS
字号:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  if (Directoryexists(Edit1.Text)) then
    ShowMessage('文件夹存在')
  else
  begin
    if Application.MessageBox(pchar('是否创建文件夹'+Edit1.Text),'提示',mb_yesno)=mryes then
    begin
      ForceDirectories(Edit1.Text);
      Edit1.Clear;
    end;
  end;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
if (DirectoryExists(Edit1.Text)) then
begin
  if Application.MessageBox(pchar('是否删除文件夹'+Edit1.Text),'提示',mb_yesno)=mryes then
  begin
    RmDir(Edit1.Text);
    Edit1.Clear;
  end;
end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -