Path::InvalidPathChars Field

obsoleteCodeEntityM:System.IO.Path.GetInvalidPathChars Note: This API is now obsolete.

Provides a platform-specific array of characters that cannot be specified in path string arguments passed to members of the Path class.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

[ObsoleteAttribute("Please use GetInvalidPathChars or GetInvalidFileNameChars instead.")]
static initonly array<wchar_t>^ InvalidPathChars

Field Value

Type: array<System::Char>^

A character array of invalid path characters for the current platform.

The array returned from this method is not guaranteed to contain the complete set of characters that are invalid in file and directory names. The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).


Do not useInvalidPathChars if you think your code might execute in the same application domain as untrusted code. InvalidPathChars is an array, so its elements can be overwritten. If untrusted code overwrites elements of InvalidPathChars, it might cause your code to malfunction in ways that could be exploited.

The following code example demonstrates the use of the InvalidPathChars property.

Console::WriteLine( "Path::AltDirectorySeparatorChar={0}", (Path::AltDirectorySeparatorChar).ToString() );
Console::WriteLine( "Path::DirectorySeparatorChar={0}", (Path::DirectorySeparatorChar).ToString() );
Console::WriteLine( "Path::PathSeparator={0}", (Path::PathSeparator).ToString() );
Console::WriteLine( "Path::VolumeSeparatorChar={0}", (Path::VolumeSeparatorChar).ToString() );
Console::Write( "Path::InvalidPathChars=" );
for ( int i = 0; i < Path::InvalidPathChars->Length; i++ )
   Console::Write( Path::InvalidPathChars[ i ] );

// This code produces output similar to the following:
// Note that the InvalidPathCharacters contain characters
// outside of the printable character set.
// Path.AltDirectorySeparatorChar=/
// Path.DirectorySeparatorChar=\
// Path.PathSeparator=;
// Path.VolumeSeparatorChar=:

.NET Framework
Available since 1.1
Return to top