본문 바로가기
Delphi/프로시저-함수

IncludeTrailingPathDelimiter로 경로 끝에 슬래시 추가하기

by MonoSoft 2025. 4. 18.
728x90
반응형

IncludeTrailingPathDelimiter로 경로 끝에 슬래시 추가하기

 

파일 또는 폴더 경로를 조합할 때 슬래시(\) 누락으로 인해 
문제가 생기는 경우가 많습니다. 
델파이의 IncludeTrailingPathDelimiter 함수는 경로 끝에 슬래시가 없으면 
자동으로 추가해줘 경로 연결 시 안전하게 사용할 수 있습니다.

uses
  System.SysUtils;

procedure JoinFolderPath;
var
  BasePath, FullPath: string;
begin
  BasePath := 'C:\MyApp\Data';
  FullPath := IncludeTrailingPathDelimiter(BasePath) + 'Backup.txt';
  ShowMessage('전체 경로: ' + FullPath);
end;

경로 끝에 슬래시가 있든 없든 관계없이 일관된 결과 보장
ExcludeTrailingPathDelimiter와 반대로 사용하면 경로 정리에 유리
파일 입출력, 백업, 로그 저장 등 경로 조합이 필요한 모든 곳에서 활용 가능



#델파이
#Delphi
#IncludeTrailingPathDelimiter
#파일경로
#경로처리
#문자열조합
#SysUtils
#파일입출력
#VCL함수
#윈도우개발

 

728x90
반응형

댓글