한 단계씩 검사하면서 없으면 생성함.



procedure CreateDir(Dir: String);
var
  i: Integer;
  Path: String;
  sList: TStringList;
begin
  sList:=TStringList.Create;
  try
    Path:='';
    ExtractStrings(['\'], [], PChar(Dir), sList);
    
    for i:=0 to sList.Count-1 do begin
      if Length(Path)>0 then Path:=Path+'\';
      Path:=Path+sList[i];
    
      if not DirectoryExists(Path) then begin
        if not CreateDirectory(PChar(Path), nil) then begin 
          OutputDebugString('CreateDirectoryFailed = ('+IntToStr(GetLastError)+') ['+Path+']');
        end;
      end;
    end;
  finally
    FreeAndNil(sList);
  end;
end;





Posted by bloodguy
,