|
03 August 2000 Ref. 32
Delphi applications will automatically make use of long file paths, but you may want to convert that long path into a short path.
You can do so by using the ExtractShortPathName function.
Declaration
-----------
function ExtractShortPathName(const FileName: string): string;
Description
-----------
ExtractShortPathName converts the file name (FileName), to the short
8.3 form.
ExtractShortPathName returns an empty string if the file or directory
does not exist.
Example
-------
uses
FileCtrl;
var
Dir : string;
begin
if (SelectDirectory('Please select any Directory', '', Dir))
then
begin
Label1.Caption := Dir;
Label2.Caption := ExtractShortPathName(Dir);
end;
end;
In this example the Windows directory browser will allow you to select any directory and will then display the long and short paths in the labels.
NOTE: Remember to add the SysUtils unit to your application's uses-clause.