Click or drag to resize

FilePath Class

This class contains information on a file, as well its name and path, and handles relative and absolute (full) paths. When path is relative, it can have a BaseFilePath, used to expand the relative filepath to an absolute (full) path. If a path is relative, and no BaseFilePath is specified, CurrentDirectory is used as BaseFilePath. Examples of legal paths: - "c:\\MyDir\\MyFile.txt" - directory and file - "c:\\MyDir" - only directory - "MyDir\\MySubdir" - relative directory - "\\\\MyServer\\MyShare" - network drive
Inheritance Hierarchy
SystemObject
  DHI.Mike1D.GenericFilePath

Namespace:  DHI.Mike1D.Generic
Assembly:  DHI.Mike1D.Generic (in DHI.Mike1D.Generic.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
[SerializableAttribute]
public class FilePath : IFilePath

The FilePath type exposes the following members.

Constructors
  NameDescription
Public methodFilePath
Creates a new FilePath without a Path set. This defaults the path to the current directory
Public methodFilePath(String)
Creates a new FilePath with the given strfilePath as Path. If the path is relative, then the current directory are used as BaseFilePath.
Public methodFilePath(IFilePath)
Creates a new FilePath with the given strfilePath as Path. If the path is relative, then the current directory are used as BaseFilePath.
Public methodFilePath(String, IFilePath)
Creates a new FilePath with the given strfilePath as Path and uses the baseFilePath as BaseFilePath
Top
Properties
  NameDescription
Public propertyBaseFilePath
If the path is relative, a BaseFilePath can be set. If a BaseFilePath is not set, then the CurrentDirectory will be used as BaseFilePath. For absolute paths, BaseFilePath is ignored. Only the directory part of the BaseFilePath is used.
Public propertyDirectoryName
Gets the directory name of the filepath. It will return relative or absolute directory, depending on whether the filepath is relative or absolute.
Public propertyExtension
Gets or alters the extension of the file. The extionsion is returned with the dot, i.e., on the form ".ext". If no extension exists, the empty string is returned. If path is null, null is returned. It can be set with or without the dot.
Public propertyFileName
Gets/alters the filename including extension
Public propertyFileNameWithoutExtension
Gets/alters the filename without the extension
Public propertyFullDirectoryName
Gets the full directory name of the filepath. It will return an absolute directory.
Public propertyFullFilePath
Gets the full directory name of the filepath, including file name. It will return an absolute directory.
Public propertyHasPath
Return true if FilePath has a Path, false if empty.
Public propertyIsRelative
Returns true if the FilePath is relative
Public propertyPath
Get/set file name including path. The path can be absolute or relative.
Public propertyRelativeDirectoryName
Gets the relative directory name of the filepath. It will return a directory relative to BaseFilePath or CurrentDirectory.
Public propertyRelativeFilePath
Gets the relative directory name of the filepath, including file name. It will return a directory relative to BaseFilePath or CurrentDirectory.
Top
Methods
  NameDescription
Public methodClone
Creates a deep clone of the FilePath
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExtensionIs
Return true if the extension of the file path is "extension".
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic memberGetRelativeFilePath
Make the filepath relative to baseDirectory. If not succeding, return original file path.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodMakePathFull
Make the Path absolute, based on either BaseFilePath or CurrentDirectory. If path is already absolute, this has no effekt.
Public methodMakePathRelative
Make the Path relative, based on either BaseFilePath or CurrentDirectory. If path is already relative, this has no effect.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
See Also