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

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

[Visual Basic]
Public Shared ReadOnly InvalidPathChars() As Char
[C#]
public static readonly char[] InvalidPathChars;
[C++]
public: static __wchar_t InvalidPathChars __gc[];
[JScript]
public static var InvalidPathChars : Char[];

Remarks

This array 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 quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0), and Unicode characters 16 through 18 and 20 through 25.

Example

[Visual Basic, C#, C++] The following example demonstrates the use of the InvalidPathChars property.

[Visual Basic] 
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=")
Dim c As Char
For Each c In Path.InvalidPathChars
    Console.Write(c)
Next c
Console.WriteLine()

[C#] 
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();

[C++] 
Console::WriteLine(S"Path::AltDirectorySeparatorChar={0}", 
   (Path::AltDirectorySeparatorChar).ToString());
Console::WriteLine(S"Path::DirectorySeparatorChar={0}", 
   (Path::DirectorySeparatorChar).ToString());
Console::WriteLine(S"Path::PathSeparator={0}", 
   (Path::PathSeparator).ToString());
Console::WriteLine(S"Path::VolumeSeparatorChar={0}", 
   (Path::VolumeSeparatorChar).ToString());

Console::Write(S"Path::InvalidPathChars=");
for (int i = 0; i < Path::InvalidPathChars->Length; i++)
   Console::Write( Path::InvalidPathChars[i]);
Console::WriteLine();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Path Class | Path Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File

Show:
© 2014 Microsoft