Class FileNameHelper
Class to secure a valid filename from a proposed filename
Inherited Members
Namespace: SuperOffice.Util
Assembly: SoCore.dll
Syntax
public static class FileNameHelper
Fields
InvalidFileNameChars
The Windows set of invalid filename characters, applied on every platform. Path.GetInvalidFileNameChars() is OS-dependent (on Linux it is only '/' and NUL), but the document archive keeps Windows filename rules everywhere so that names are portable.
Declaration
public static readonly char[] InvalidFileNameChars
Field Value
| Type | Description |
|---|---|
| char[] |
InvalidFileNameCharsPattern
Regex character-class pattern matching InvalidFileNameChars.
Declaration
public static readonly string InvalidFileNameCharsPattern
Field Value
| Type | Description |
|---|---|
| string |
Methods
GetFileNameAnyPlatform(string)
Get the file name (last segment) of a path, treating both '/' and '' as directory separators regardless of host OS. Path.GetFileName does not strip Windows-style directories on Linux, but Windows clients send such paths to Linux servers.
Declaration
public static string GetFileNameAnyPlatform(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | A file name, optionally prefixed by a path in either separator style |
Returns
| Type | Description |
|---|---|
| string | The file name without any directory or drive designator |
MakeLegalFileName(string)
Class to secure a valid filename from a proposed filename
Declaration
public static string MakeLegalFileName(string fileNameWithoutPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileNameWithoutPath |
Returns
| Type | Description |
|---|---|
| string |