Show / Hide Table of Contents

Class FileNameTricks

This class exposes numerous static methods for manipulating file names. Unlike the objects in the System.File namespace, these methods don't need a real file object. All work on strings that represent file names.

Inheritance
System.Object
FileNameTricks
Namespace: WizardWrx
Assembly: WizardWrx.Core.dll
Syntax
public static class FileNameTricks : object

Fields

| Improve this Doc View Source

OS_DRIVE_PATH_DELIMITER

Along with the OS extension delimiter, the sequence of volume separator, followed immediately by a directory separator, is undefined, though one could easily be constructed at run time, although such a construction wouldn't qualify as a constant.

Declaration
public const string OS_DRIVE_PATH_DELIMITER = null
Field Value
Type Description
System.String
See Also
OS_WILD_CARD_MULTIPLE
OS_WILD_CARD_SINGLE
OS_EXTENSION_DELIM
UNC_SERVER_DELIM
| Improve this Doc View Source

OS_EXTENSION_DELIM

Use this to insert an extension delimiter into a file specification, since there seems to be nothing in the System.IO namespace.

Declaration
public const char OS_EXTENSION_DELIM = null
Field Value
Type Description
System.Char
Remarks

Strangely, I haven't found a property that returns the extension delimiter.

See Also
OS_DRIVE_PATH_DELIMITER
UNC_SERVER_DELIM
OS_WILD_CARD_MULTIPLE
OS_WILD_CARD_SINGLE
| Improve this Doc View Source

OS_WILD_CARD_MULTIPLE

Declaration
public const char OS_WILD_CARD_MULTIPLE = null
Field Value
Type Description
System.Char
Remarks

There doesn't appear to be any provision for generating these from anything in the System.IO namespace.

See Also
OS_WILD_CARD_SINGLE
OS_EXTENSION_DELIM
OS_DRIVE_PATH_DELIMITER
UNC_SERVER_DELIM
| Improve this Doc View Source

OS_WILD_CARD_SINGLE

Use this to insert a multiple-character wild card character into a Windows or Unix file name mask.

Declaration
public const char OS_WILD_CARD_SINGLE = null
Field Value
Type Description
System.Char
Remarks

There doesn't appear to be any provision for generating these from anything in the System.IO namespace.

See Also
OS_WILD_CARD_MULTIPLE
OS_EXTENSION_DELIM
OS_DRIVE_PATH_DELIMITER
UNC_SERVER_DELIM
| Improve this Doc View Source

UNC_SERVER_DELIM

The server delimiter string.

Declaration
public const string UNC_SERVER_DELIM = null
Field Value
Type Description
System.String
See Also
OS_DRIVE_PATH_DELIMITER
OS_EXTENSION_DELIM
OS_WILD_CARD_MULTIPLE
OS_WILD_CARD_SINGLE

Methods

| Improve this Doc View Source

EnsureHasTerminalBackslash(String)

Ensure that a path string has NO terminal backslash.

Declaration
public static string EnsureHasTerminalBackslash(string pstrInputPath)
Parameters
Type Name Description
System.String pstrInputPath

String to evaluate and change if needed.

Returns
Type Description
System.String

Path string that is guaranteed to HAVE a terminal backslash.

Remarks

This method is deprecated. Use PathAddBackslash.

| Improve this Doc View Source

EnsureNoTerminalBackslash(String)

Ensure that a path string has a terminal backslash.

Declaration
public static string EnsureNoTerminalBackslash(string pstrInputPath)
Parameters
Type Name Description
System.String pstrInputPath

String to evaluate and change if needed.

Returns
Type Description
System.String

Path string that is guaranteed NOT to have a terminal backslash.

Remarks

This method is deprecated. Use PathRemoveBackslash.

| Improve this Doc View Source

FileDirName(String, FileNameTricks.TerminaBackslash)

Extract the directory name from a fully qualified file name.

Declaration
public static string FileDirName(string pstrFQFN, FileNameTricks.TerminaBackslash penmTerminaBackslash)
Parameters
Type Name Description
System.String pstrFQFN

String containing file name to evaluate.

FileNameTricks.TerminaBackslash penmTerminaBackslash

A member of the TerminaBackslash, which specifies whether the returned string should have a terminal backslash.

Returns
Type Description
System.String

If the function succeeds, the return value is the directory name stripped of its file name.

| Improve this Doc View Source

FileExtn(String)

Given a string that contains a partially or fully qualified file name, return the extension, without the delimiting dot.

Declaration
public static string FileExtn(string pstrFQFN)
Parameters
Type Name Description
System.String pstrFQFN

File name string to evaluate.

Returns
Type Description
System.String

Extension, less the delimiting dot.

| Improve this Doc View Source

FQFBasename(String)

Extract the fully qualified base name, that is, all but the extension, from a partially or fully qualified file name.

Declaration
public static string FQFBasename(string pstrFQFN)
Parameters
Type Name Description
System.String pstrFQFN

Fully or partially qualified file name to evaluate.

Returns
Type Description
System.String

All of pstrFQFN except its extension and extension delimiter.

| Improve this Doc View Source

MakeFQFN(String, String)

Given a file name and a default directory, which may be a null reference or an empty string, return a file name that is guaranteed to be fully qualified.

Declaration
public static string MakeFQFN(string pstrUQFN, string pstrDefaultDir)
Parameters
Type Name Description
System.String pstrUQFN

String which is assumed to be a relative file name.

System.String pstrDefaultDir

String to use as a default path, unless argument pstrUQFN is a fully qualified file name.

If this value is null, or an empty string, the current working directory is used.

Returns
Type Description
System.String

String that contains a string that is guaranteed to represent a fully qualified file name.

| Improve this Doc View Source

PathAddBackslash(String)

Ensure that a path string has NO terminal backslash.

Declaration
public static string PathAddBackslash(string pstrInputPath)
Parameters
Type Name Description
System.String pstrInputPath

String to evaluate and change if needed.

Returns
Type Description
System.String

Path string that is guaranteed to HAVE a terminal backslash.

| Improve this Doc View Source

PathAddBackslashDeprecated1(String)

Ensure that a path string has NO terminal backslash.

Declaration
public static string PathAddBackslashDeprecated1(string pstrInputPath)
Parameters
Type Name Description
System.String pstrInputPath

String to evaluate and change if needed.

Returns
Type Description
System.String

Path string that is guaranteed to HAVE a terminal backslash.

| Improve this Doc View Source

PathAddBackslashDeprecated2(String)

Ensure that a path string has NO terminal backslash.

Declaration
public static string PathAddBackslashDeprecated2(string pstrInputPath)
Parameters
Type Name Description
System.String pstrInputPath

String to evaluate and change if needed.

Returns
Type Description
System.String

Path string that is guaranteed to HAVE a terminal backslash.

| Improve this Doc View Source

PathFixup(String, FileNameTricks.TerminaBackslash)

Originally a private method, this method returns a path (directory) name string that is guaranteed to meet the specified requirement, with respect to presence or absence of a terminal backslash.

Declaration
public static string PathFixup(string pstrInputPath, FileNameTricks.TerminaBackslash penmBackslash)
Parameters
Type Name Description
System.String pstrInputPath

String containing path (directory) name to evaluate.

FileNameTricks.TerminaBackslash penmBackslash

A member of the TerminaBackslash, which specifies whether the returned string should have a terminal backslash.

Returns
Type Description
System.String

Path (directory) name string that is guaranteed to either have, or omit, a terminal backslash, as specified.

| Improve this Doc View Source

PathMakeRelative(String, String)

Given a path, such as the fully qualified name of a resource DLL, and a second fully qualified name, such as that of the program directory or current working directory, compute a relative path to the first named path.

Declaration
public static string PathMakeRelative(string pstrFQPath, string pstrDirectoryRelativeTo)
Parameters
Type Name Description
System.String pstrFQPath

This string is the fully qualified path for which a relative path is required. This string may be the name of a file or a directory, but it must exist in the file system.

System.String pstrDirectoryRelativeTo

This string is the fully qualified path relative to which a path to pstrFQPath is required. This string may be the name of a file or a directory, but it must exist in the file system. Whether you supply a file name or that of its directory, the outcome is the same, since this has no effect on the relative path to pstrFQPath.

Returns
Type Description
System.String

The returned string is a relative path string, ready for use.

Remarks

This method uses methods of the System.Uri class to perform its path math, taking advantage of the fact that a path in the file system is a valid URI.

| Improve this Doc View Source

PathRemoveBackslash(String)

Ensure that a path string has a terminal backslash.

Declaration
public static string PathRemoveBackslash(string pstrInputPath)
Parameters
Type Name Description
System.String pstrInputPath

String to evaluate and change if needed.

Returns
Type Description
System.String

Path string that is guaranteed NOT to have a terminal backslash.

| Improve this Doc View Source

UQFBasename(String)

Given a string that represents the name of a file, extract only the base name (EXCLUDING the extension).

Declaration
public static string UQFBasename(string pstrFQFN)
Parameters
Type Name Description
System.String pstrFQFN

String to evaluate.

Returns
Type Description
System.String

Base name extracted from string. This means the unqualified file name, less its directory and its extension.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX