Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Path.InvalidPathChars Field

NOTE: This field 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.")] 
public static readonly char[] InvalidPathChars
/** @attribute ObsoleteAttribute("Please use GetInvalidPathChars or GetInvalidFileNameChars instead.") */ 
public static final char[] InvalidPathChars
ObsoleteAttribute("Please use GetInvalidPathChars or GetInvalidFileNameChars instead.") 
public static final var InvalidPathChars : 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).

Caution noteCaution

Do not use InvalidPathChars 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);
Console.WriteLine("Path.DirectorySeparatorChar={0}", 
    Path.DirectorySeparatorChar);
Console.WriteLine("Path.PathSeparator={0}", 
    Path.PathSeparator);
Console.WriteLine("Path.VolumeSeparatorChar={0}", 
    Path.VolumeSeparatorChar);

Console.Write("Path.InvalidPathChars=");
foreach (char c in Path.InvalidPathChars)
    Console.Write(c);
Console.WriteLine();
// 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=:

Console.WriteLine("Path.AltDirectorySeparatorChar={0}", 
    System.Convert.ToString(Path.AltDirectorySeparatorChar));
Console.WriteLine("Path.DirectorySeparatorChar={0}", 
    System.Convert.ToString(Path.DirectorySeparatorChar));
Console.WriteLine("Path.PathSeparator={0}", 
    System.Convert.ToString(Path.PathSeparator));
Console.WriteLine("Path.VolumeSeparatorChar={0}", 
    System.Convert.ToString (Path.VolumeSeparatorChar));

Console.Write("Path.InvalidPathChars=");

for(int iCtr=0; iCtr<Path.InvalidPathChars.length;iCtr++) {
    char c = Path.InvalidPathChars[iCtr];
    Console.Write(c);
}
Console.WriteLine();

Console.WriteLine("Path.AltDirectorySeparatorChar={0}", 
                  Path.AltDirectorySeparatorChar);
Console.WriteLine("Path.DirectorySeparatorChar={0}", 
                  Path.DirectorySeparatorChar);
Console.WriteLine("Path.PathSeparator={0}", 
                  Path.PathSeparator);
Console.WriteLine("Path.VolumeSeparatorChar={0}", 
                  Path.VolumeSeparatorChar);

Console.Write("Path.InvalidPathChars=");
for (var c : char in Path.InvalidPathChars)
    Console.Write(c);
Console.WriteLine();

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 1.0, 1.1
Obsolete (compiler warning) in 2.0

.NET Compact Framework

Supported in: 1.0
Obsolete (compiler warning) in 2.0

Community Additions

Show:
© 2014 Microsoft