delphi 判断文件路径,不存在则建立


本文整理自网络,侵删。

  procedure TForm1.Act_CheckPath(FilePath:String);
var
MyFile:String;
i:Integer;
FileDir,TemStr:WideString;
PosList,DirList:TStrings;
begin
PosList:=TStringList.Create;
DirList:=TStringList.Create;
MyFile:=FilePath+'\';
FileDir:=MyFile;
//记录'\'的位置;
for i:=1 to Length(FileDir) do
begin
TemStr:=Copy(FileDir,i,1);
if TemStr = '\' then
PosList.Add(IntToStr(i));
end;
for i:=0 to PosList.Count - 1 do
begin
DirList.Add(Copy(FileDir,1,StrToInt(PosList.Strings[i])-1));
end;
for i:=0 to DirList.Count -1 do
begin
//判断文件路径是否存在
if not DirectoryExists(DirList.Strings[i]) then
//不存在,则建立新路径
CreateDir(DirList.Strings[i]);
end;
PosList.Free;
DirList.Free;
end;

相关阅读 >>

Delphi fmx用timage显示不同格式的图片

Delphi程序不受windows日期格式的影响

Delphi 百万次重复调用字符分割函数,不耗内存用法

Delphi与sql server存储过程编程详解

Delphi access 从数据库里随机选择一行

Delphi多线程图片转换类实现

Delphi filesearch 获取指定文件夹下所有文件包括隐藏文件

Delphi 免杀下载者源代码

Delphi 在ie上增添一个按钮

Delphi debug和release区别

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...