The standard MkDir() function can create only one directory, it can not create subdirectories at one time. This function allows you to create multiple directories (directories inside directories). Delphi 4+ have the ForceDirectories() routine which does the same thing. It is declared in the FileCtrl unit.
uses
SysUtils, FileCtrl;
...
procedure MkDirMulti(sPath: string);
begin
if sPath[Length(sPath)] = '' then
sPath := Copy(sPath, 1, Length(sPath - 1));
if (Length(sPath) < 3) or DirectoryExists(sPath) then
Exit;
MkDirMulti(SysUtils.ExtractFilePath(sPath));
try
MkDir(sPath);
except
{ Handle errors }
end;
end;
Example: MkDirMulti(’C:Program FilesMy GameAudioSpeech’);
Tags: borland, c program, code, codegear, create, Delphi, delphi 4, directories, folder, folders, force, forcedirectories, Kylix, make, mkdir, mkdirmulti, one time, source
Merlin’s Delphi Forge
Leave a comment