class System::IO::Path

Provides functions dealing with pathes to files and directories on the local filesystem and network shares.

Global Functions

int DeleteDirectory (const Path, const int)Deletes the specified directory from the file system.
int Exists (const Path)Returns true if the specified file or directory exists.
Path GetCurrentDirectory ()Returns the current working directory for the application.
Path[] GetDirectories (const Path)Returns an array containing all sub-directories contained in the specified path.
Path[] GetFiles (const Path)Returns an array containing all files contained in the specified path.
int IsFolder (const Path)Returns true if the specified path is a directory.
int MakeDirectory (const Path)Creates a new directory under the specified path.
Path NewTempDirectory (const int)Returns a path for a new temp directory.
Path NewTempFile (const Path)Returns a path for a new temp file in the given directory.
int SetCurrentDirectory (const Path)Sets the current working directory for the application.

Constructors

Path ()Constructs a new, empty path.
Path (const string)Constructs an instance from the given string.
Path (const string, const int)Constructs an instance from a string and a flag indicating whether the string is a path to a file or folder.
Path (const Path)Constructs a copy from the given instance.
Path (const Path, const string)Constructs new path from an existing path and a file name.

Convertors

string convertor ()Returns a string representation of this path object.

Methods

AddFolder (const string)Appends a folder name to the list of folders in this path.
string[] GetFolderNames ()Returns all folder names of the path as an array of strings.
RemoveFolder ()Removes the last folder from the list of folders in this path.
SetFolderNames (const string[])Sets all folder names of the path to the contents of the given array.

Properties

string CompleteName ()Returns the complete file name of this path.
CompleteName (const string)Sets a new file name and extension for this path.
string Drive ()Returns the drive letter or network share name of this path.
Drive (const string)Sets the drive letter or network share name of this path.
string DriveAndFolders ()Returns the drive letter or network share name and all folders of this path, but not the file name and type.
DriveAndFolders (const string)Sets the drive name and all folders of this path.
string FileName ()Returns the file name of this path.
FileName (const string)Sets a new file name for this path.
string FileType ()Returns the file type of this path.
FileType (const string)Sets the file type for this path.
string Folders ()Returns all folders of this path.
Folders (const string)Sets all folders of this path.
string FullPath ()Returns the complete path to the file represented by this path as a string.
FullPath (const string)Sets this path to a new file.
int IsAbsolute ()Returns true if this path is absolute, meaning it contains a drive letter and the full path to the file or directory represented by the path.
int IsEmpty ()Returns true if this path does not contain any file or path information at all.
int IsShare ()Returns true if this path represents a file or directory on a network share, rather than a local drive.

Type Declaration

native class System::IO::Path
{
    ["Provides functions dealing with pathes to files and directories on the local filesystem and network shares."]
    method Path (); ["Constructs a new, empty path."]
    method Path (const string filePath); ["Constructs an instance from the given string. This assumes the given string is a file; if you want to create a path to a directory, use the third constructor."]
    method Path (const string path, const int isFolder); ["Constructs an instance from a string and a flag indicating whether the string is a path to a file or folder."]
    method Path (const Path source); ["Constructs a copy from the given instance."]
    method Path (const Path source, const string fileName); ["Constructs new path from an existing path and a file name."]
    method string convertor (); ["Returns a string representation of this path object. The result will be the same as the FullPath property."]
    accessor string FullPath (); ["Returns the complete path to the file represented by this path as a string."]
    accessor FullPath (const string); ["Sets this path to a new file. This assumes the given string is a file; if you want to assign a path to a directory, use the DriveAndFolders property instead."]
    accessor string Drive (); ["Returns the drive letter or network share name of this path."]
    accessor Drive (const string); ["Sets the drive letter or network share name of this path. The other attributes of the path object are not affected by this."]
    accessor string Folders (); ["Returns all folders of this path. This is the path name stripped by the drive letter and file name."]
    accessor Folders (const string); ["Sets all folders of this path. The other attributes of the path are not affected."]
    accessor string DriveAndFolders (); ["Returns the drive letter or network share name and all folders of this path, but not the file name and type."]
    accessor DriveAndFolders (const string); ["Sets the drive name and all folders of this path. The file name and type will not be affected."]
    accessor string CompleteName (); ["Returns the complete file name of this path. This includes the file's extension, but not folders and drive letter."]
    accessor CompleteName (const string); ["Sets a new file name and extension for this path. This will update the FileType property. The other attributes are not affected."]
    accessor string FileName (); ["Returns the file name of this path. This is the name of the file without extension."]
    accessor FileName (const string); ["Sets a new file name for this path. This will also update the CompleteName property. The other attributes are not affected."]
    accessor string FileType (); ["Returns the file type of this path. The file type is the extension of the file, NOT including the dot character."]
    accessor FileType (const string); ["Sets the file type for this path. This will also alter the CompleteName property to reflect the new extension. The other attributes are not affected."]
    accessor int IsEmpty (); ["Returns true if this path does not contain any file or path information at all."]
    accessor int IsAbsolute (); ["Returns true if this path is absolute, meaning it contains a drive letter and the full path to the file or directory represented by the path."]
    accessor int IsShare (); ["Returns true if this path represents a file or directory on a network share, rather than a local drive."]
    method AddFolder (const string folder); ["Appends a folder name to the list of folders in this path."]
    method RemoveFolder (); ["Removes the last folder from the list of folders in this path."]
    method string[] GetFolderNames (); ["Returns all folder names of the path as an array of strings."]
    method SetFolderNames (const string[] folders); ["Sets all folder names of the path to the contents of the given array."]
    function int Exists (const Path path); ["Returns true if the specified file or directory exists."]
    function int IsFolder (const Path path); ["Returns true if the specified path is a directory."]
    function int SetCurrentDirectory (const Path path); ["Sets the current working directory for the application."]
    function Path GetCurrentDirectory (); ["Returns the current working directory for the application."]
    function Path[] GetDirectories (const Path path); ["Returns an array containing all sub-directories contained in the specified path."]
    function Path[] GetFiles (const Path path); ["Returns an array containing all files contained in the specified path."]
    function Path NewTempDirectory (const int create); ["Returns a path for a new temp directory. If 'create' is true, the function will automatically create this directory. When the directory is no longer needed, remove it using DeleteDirectory()."]
    function Path NewTempFile (const Path path); ["Returns a path for a new temp file in the given directory."]
    function int MakeDirectory (const Path path); ["Creates a new directory under the specified path. If the function succeeds, the result is true."]
    function int DeleteDirectory (const Path path, const int force); ["Deletes the specified directory from the file system. If 'force' is true, the directory will be deleted even if containing files. If the directory contains sub-directories, system files, hidden files or read-only files, the function will fail. If the function succeeds, the result is true."]
}

Reference

function int DeleteDirectory (const Path path, const int force)

Deletes the specified directory from the file system.

If 'force' is true, the directory will be deleted even if containing files. If the directory contains sub-directories, system files, hidden files or read-only files, the function will fail. If the function succeeds, the result is true.


function int Exists (const Path path)

Returns true if the specified file or directory exists.


function Path GetCurrentDirectory ()

Returns the current working directory for the application.


function Path[] GetDirectories (const Path path)

Returns an array containing all sub-directories contained in the specified path.


function Path[] GetFiles (const Path path)

Returns an array containing all files contained in the specified path.


function int IsFolder (const Path path)

Returns true if the specified path is a directory.


function int MakeDirectory (const Path path)

Creates a new directory under the specified path.

If the function succeeds, the result is true.


function Path NewTempDirectory (const int create)

Returns a path for a new temp directory.

If 'create' is true, the function will automatically create this directory. When the directory is no longer needed, remove it using DeleteDirectory().


function Path NewTempFile (const Path path)

Returns a path for a new temp file in the given directory.


function int SetCurrentDirectory (const Path path)

Sets the current working directory for the application.


method Path ()

Constructs a new, empty path.


method Path (const string filePath)

Constructs an instance from the given string.

This assumes the given string is a file; if you want to create a path to a directory, use the third constructor.


method Path (const string path, const int isFolder)

Constructs an instance from a string and a flag indicating whether the string is a path to a file or folder.


method Path (const Path source)

Constructs a copy from the given instance.


method Path (const Path source, const string fileName)

Constructs new path from an existing path and a file name.


method string convertor ()

Returns a string representation of this path object.

The result will be the same as the FullPath property.


method AddFolder (const string folder)

Appends a folder name to the list of folders in this path.


method string[] GetFolderNames ()

Returns all folder names of the path as an array of strings.


method RemoveFolder ()

Removes the last folder from the list of folders in this path.


method SetFolderNames (const string[] folders)

Sets all folder names of the path to the contents of the given array.


accessor string CompleteName ()

Returns the complete file name of this path.

This includes the file's extension, but not folders and drive letter.


accessor CompleteName (const string)

Sets a new file name and extension for this path.

This will update the FileType property. The other attributes are not affected.


accessor string Drive ()

Returns the drive letter or network share name of this path.


accessor Drive (const string)

Sets the drive letter or network share name of this path.

The other attributes of the path object are not affected by this.


accessor string DriveAndFolders ()

Returns the drive letter or network share name and all folders of this path, but not the file name and type.


accessor DriveAndFolders (const string)

Sets the drive name and all folders of this path.

The file name and type will not be affected.


accessor string FileName ()

Returns the file name of this path.

This is the name of the file without extension.


accessor FileName (const string)

Sets a new file name for this path.

This will also update the CompleteName property. The other attributes are not affected.


accessor string FileType ()

Returns the file type of this path.

The file type is the extension of the file, NOT including the dot character.


accessor FileType (const string)

Sets the file type for this path.

This will also alter the CompleteName property to reflect the new extension. The other attributes are not affected.


accessor string Folders ()

Returns all folders of this path.

This is the path name stripped by the drive letter and file name.


accessor Folders (const string)

Sets all folders of this path.

The other attributes of the path are not affected.


accessor string FullPath ()

Returns the complete path to the file represented by this path as a string.


accessor FullPath (const string)

Sets this path to a new file.

This assumes the given string is a file; if you want to assign a path to a directory, use the DriveAndFolders property instead.


accessor int IsAbsolute ()

Returns true if this path is absolute, meaning it contains a drive letter and the full path to the file or directory represented by the path.


accessor int IsEmpty ()

Returns true if this path does not contain any file or path information at all.


accessor int IsShare ()

Returns true if this path represents a file or directory on a network share, rather than a local drive.