在创建函数时需要一些帮助,该函数可以通过给定路径递归创建文件夹:
C:\TestFolder\Another\AndAnother
Delphi函数MkDir返回IOerror = 3。
MkDir('C:\TestFolder\Another\AndAnother');
使用
ForceDirectories('C:\TestFolder\Another\AndAnother');
((这是在SysUtils.pas中找到的标准RTL函数。因此,即使不是很困难,也不需要创建自己的函数。)
这将使用新的IOUtils而不是SysUtils。IOUtils是跨平台兼容的,并且支持UNC。
function ForceDirectories(FullPath: string): Boolean; // Works with UNC paths
begin
TDirectory.CreateDirectory(FullPath);
Result:= DirectoryExists(FullPath);
end;