The following example creates a directory 慍:\temp?if it does not already exist.uses FileCtrl;procedure TForm1.Button1Click(Sender: TObject); begin if not DirectoryExists('c:\temp') then if not CreateDir('C:\temp') then raise Exception.Create('Cannot create c:\temp'); end;{这是delphi版的}
void __fastcall TForm1::Button1Click(TObject *Sender){
if (!DirectoryExists("c:\\temp"))
{
if (!CreateDir("C:\\temp"))
throw Exception("Cannot create c:\\temp directory.");
}
}
ifnot CreateDir('C:\temp') then
raise Exception.Create('Cannot create c:\temp');
创建单级目录用CreateDir,多级目录要用ForceDirectories。
begin
if not DirectoryExists('c:\temp') then
if not CreateDir('C:\temp') then
raise Exception.Create('Cannot create c:\temp');
end;{这是delphi版的}