如果不存在此目录就创建它:
if not DirectoryExists(path1) then
if not CreateDir(path1) then
raise Exception.Create('Cannot create '+path1);但不存在的时候报错,没有这个目录,看来是没有自动创建目录啊,why?
if not DirectoryExists(path1) then
if not CreateDir(path1) then
raise Exception.Create('Cannot create '+path1);但不存在的时候报错,没有这个目录,看来是没有自动创建目录啊,why?
begin
if not DirectoryExists('d:\tmp') then
if not CreateDir('d:\tmp') then
raise Exception.Create('Cannot create '+'d:\tmp');end;
path1:=trim(gmSysPath+'\'+daystr);但当没有此目录时报错
procedure TForm1.Button5Click(Sender: TObject);
var
path1:string;
begin
path1:=trim(extractfilepath(application.ExeName)+'\'+'123');
if not DirectoryExists(path1) then
if not CreateDir(path1) then
raise Exception.Create('Cannot create '+path1);
end;
这样也好用啊!