Method filesystem.more.createSymbolicLink
Overload
Creates a NTFS symbolic link or junction.
public static void createSymbolicLink(string linkPath, string targetPath, CSLink type, bool elevate = false, bool deleteOld = false)
Parameters
|
linkPath (string)
Full path of the link. Supports environment variables etc. |
|
targetPath (string)
If type is |
|
type (CSLink)
Enum: File, Directory, Junction, JunctionOrSymlink. |
|
elevate (bool)
If fails to create symbolic link because this process does not have admin rights, run |
|
deleteOld (bool)
If linkPath already exists as a symbolic link or junction or empty directory, replace it. |
Exceptions
|
ArgumentException
Not full path. |
|
AuException
Failed. |
Remarks
Some reasons why this function can fail:
- The link already exists. Solution: use
deleteOld: true. - This process is running not as administrator. Solution: use type
Junctionorelevate: true. To create symbolic links without admin rights, in Windows Settings enable developer mode. - The file system format is not NTFS. For example FAT32 in USB drive.
More info: CreateSymbolicLink, mklink, NTFS symbolic links, junctions.