DelphiBasics
ChangeFileExt
Function
Change the extension part of a file name SysUtils unit
 function ChangeFileExt ( const FileName, Extension : string ) : string;
Description
The ChangeFileExt function changes the Extension value of a file FileName, returning the new value as a string.
Related commands
ExtractFileExt Extracts the extension part of a full file name
ProcessPath Split a drive/path/filename string into its constituent parts
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.


 
Example code : Renaming Unit1.dcu to Unit1.old
var
  oldName, newName : string;

begin
  // Try to rename the current Unit1.dcu to Uni1.old
  oldName := 'Unit1.dcu';
  newName := ChangeFileExt(oldName, '.new');

  // Show the old and new values
  ShowMessage('Old name = '+oldName);
  ShowMessage('New name = '+newName);
end;
Show full unit code
   Old name = Unit1.dcu
   New name = Unit1.new
 
Delphi Programming Neil Moffatt 2002 - 2016. All rights reserved.  |  Home Page