Home  |  Delphi .net Home  |  System.IO.Path  |  GetFileName Method
GetFileName  
Method  
Gets the FileName from the specified Path string
Path Class
System.IO NameSpace
CF1.  Function GetFileName ( PathString : String; ) : String; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The GetFileName method extracts the file name from the given PathString as the return string. The file name includes the extension (plus . prefix), if present.
Microsoft MSDN Links
System.IO
System.IO.Path
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  PathString : String;

begin
  PathString := 'C:\My Documents\DelphiBasics.txt';

  Console.WriteLine('"{0}" has file name "{1}"',
                    PathString,
                    System.IO.Path.GetFileName(PathString));

  Console.Readline;
end.
Show full unit code
  "C:\My Documents\DelphiBasics.txt" has file name "DelphiBasics.txt"
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author