Delphi学习笔记 – 创建和删除文件夹

forcedirectories函数用于创建一个DIR参数指定的但系统中不存在的文件夹;
rmidir函数用于删除一个参数指定的子目录。
Delphi创建和删除文件夹源代码:
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);
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;
看看还有没有您感兴趣的:
既然来了,就写两句吧~
好好学习,确实要科学分析才能真正了解这个东西的,收藏一下。谢谢版主。...