if not DirectoryExists('c:\temp') then if not CreateDir('C:\temp') then raise Exception.Create('Cannot create c:\temp');
SetCurrentDir函数是不能创建不存在的文件夹
procedure TForm1.Button1Click(Sender: TObject);var Dir: string; begin Dir := 'C:\APPS\SALES\LOCAL';//这个目录可以自己定义 if DirectoryExists(Dir) then Label1.Caption := Dir + ' was created'end;
关于创建的用法 unit Unit1;interfaceuses Windows, Messages, filectrl ,SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var dest:string; begin dest:='f:/dd'; ForceDirectories(dest);end;end.
if not CreateDir('C:\temp') then
raise Exception.Create('Cannot create c:\temp');
Dir: string;
begin Dir := 'C:\APPS\SALES\LOCAL';//这个目录可以自己定义 if DirectoryExists(Dir) then
Label1.Caption := Dir + ' was created'end;
unit Unit1;interfaceuses
Windows, Messages, filectrl ,SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
dest:string;
begin
dest:='f:/dd';
ForceDirectories(dest);end;end.