JCL Help:FindUnusedFileName

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Returns a unique filename composed of the specified parts and a unique number.


Pascal

 function FindUnusedFileName(FileName: string; const FileExt: string; NumberPrefix: string = ''): string;


Parameters

Parameters Description
FileName: string Name part of the filename
const FileExt: string Extension part of the filename
NumberPrefix: string = '' Optional text that is inserted before the unique number


Return Value

A unique filename composed of the specified parts and a number to make it unique.


Description

FindUnusedFileName returns a unique filename composed of the FileName, NumberPrefix, a sequential number and FileExt. If a file of the form FileName.FileExt doesn't exist, this is returned. If such a file already exists, NumberPrefix and a sequential number are appended to FileName. e.g. FindUnusedFileName('c:MyFile', '.txt', '.backup-') would return the first unused filename in the following list: c:MyFile.txt c:MyFile.backup-1.txt c:MyFile.backup-2.txt etc.


About

Unit

JclFileUtils


Donator

Anthony Steele


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page