RTL.SymLink Sample
From RAD Studio XE2 Code Examples
Language:
Contents |
This sample demonstrates how to create a symbolic link for a file.
Location
You can find the SymLink sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples > Delphi > RTL > SymLink
- Subversion Repository for Delphi: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/Delphi/RTL/SymLink/
Description
This sample is a Delphi console application that allows the user to create a symbolic link file for a target file.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open symlink.dproj.
- Build symlink.exe.
- You can either:
- Set the names of the symlink file and target file in the Run > Parameters dialog and then press F9 or choose Run > Run.
- In the command line, navigate to the folder where the symlink executable was created and use the symlink [LinkFile] [TargetFile] command.
Files
The project has one file, symlink.dpr, which contains the main program source module.
Classes
There are no classes in this application. The .dpr file is responsible for creating the symbolic link file based on the command-line parameters provided by the user.
Implementation
- The TFile.CreateSymLink method is used to create the symbolic link file.
- ParamCount and ParamStr are the functions used to handle the command-line parameters.
- In order to create the symlink file, it must not already exist.