Mono Class Library: Mono.Unix.UnixFileSystemInfo Overview | Members

Mono.Unix.UnixFileSystemInfo.CreateSymbolicLink Method

Create a symbolic link so that path "points to" UnixFileSystemInfo.FullName. [Edit]

public UnixSymbolicLinkInfo CreateSymbolicLink (string path)

See Also

Mono.Unix.Native.Syscall.symlink

Parameters

path
A string containing the name of the symbolic link to create. [Edit]

Returns

A Mono.Unix.UnixSymbolicLinkInfo instance containing information about the created symbolic link. [Edit]

Exceptions

TypeReason
UnauthorizedAccessExceptionSearch permission is denied for a component of the path UnixFileSystemInfo.FullName or path. [Mono.Unix.Native.Errno.EACCES] [Edit]
System.IO.DirectoryNotFoundException A component of the path prefix of UnixFileSystemInfo.FullName is not a directory. [Mono.Unix.Native.Errno.ENOTDIR] [Edit]
System.IO.FileNotFoundException A component of UnixFileSystemInfo.FullName that must exist does not exist. [Mono.Unix.Native.Errno.ENOENT] [Edit]
System.IO.PathTooLongExceptionUnixFileSystemInfo.FullName was too long. [Mono.Unix.Native.Errno.ENAMETOOLONG] [Edit]
System.IO.IOException

path resides on a read-only file system. [Mono.Unix.Native.Errno.EROFS]

-or-

The directory containing path cannot be extended because there is no space left on the file system containing the directory. [Mono.Unix.Native.Errno.ENOSPC]

-or-

There are no free inodes on the file system on which the file is being created. [Mono.Unix.Native.Errno.ENOSPC]

-or-

An I/O error occurred while making the directory entry or allocating the inode. [Mono.Unix.Native.Errno.EIO]

[Edit]
Mono.Unix.UnixIOException

Too many symbolic links were encountered in translating UnixFileSystemInfo.FullName. [Mono.Unix.Native.Errno.ELOOP]

-or-

The user's quota of inodes on the file system containing UnixFileInfo.Directory has been exhausted. [Mono.Unix.Native.Errno.EDQUOT]

-or-

The directory containing path cannot be extended because the user's quota of disk blocks on the file system containing this directory has been exhausted. [Mono.Unix.Native.Errno.EDQUOT]

-or-

path already exists.

[Edit]

Remarks

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.

Note: To obtain the current working directory, see UnixDirectoryInfo.GetCurrentDirectory.

The created symbolic link will contain the full path name, UnixFileSystemInfo.FullName. If this is undesirable (for instance, you want the created symbolic link to contain relative path information), use UnixSymbolicLinkInfo.CreateSymbolicLinkTo instead. UnixSymbolicLinkInfo.CreateSymbolicLinkTo uses the exact path provided to the Mono.Unix.UnixSymbolicLinkInfo constructor when creating the symbolic link, while this method uses the fully-qualified file name to create the symbolic link.

The ln(1) command:

sh Example
ln -s target symlink

Can be created using Mono.Unix in two ways. First, it can be created using UnixFileSystemInfo.CreateSymbolicLink:

C# Example
UnixFileInfo f = new UnixFileInfo ("target.ufi");
f.CreateSymbolicLink ("symlink.ufi");

Second, it can be created using UnixSymbolicLinkInfo.CreateSymbolicLinkTo:

C# Example
UnixSymbolicLinkInfo s = 
    new UnixSymbolicLinkInfo ("symlink.usli");
s.CreateSymbolicLinkTo ("target.usli");

The links created by the above differ; in particular, the target of UnixFileSystemInfo.CreateSymbolicLink is the full path name of the target, while UnixSymbolicLinkInfo.CreateSymbolicLinkTo contains no extra information:

sh Example
$ ls -lF symlink* | cut -c 39-
symlink -> target
symlink.ufi -> /full/path/to/target.ufi
symlink.usli -> target.usli
            
[Edit]

Requirements

Namespace: Mono.Unix
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0