Path.InvalidPathChars Path.InvalidPathChars Path.InvalidPathChars Path.InvalidPathChars Field

定義

警告

此 API 現已淘汰。

提供字元的平台特定陣列,這些字元不可以在傳遞給 Path 類別成員的路徑字串引數中指定。Provides a platform-specific array of characters that cannot be specified in path string arguments passed to members of the Path class.

public: static initonly cli::array <char> ^ InvalidPathChars;
[System.Obsolete("see GetInvalidPathChars and GetInvalidFileNameChars methods.")]
[System.Obsolete("Please use GetInvalidPathChars or GetInvalidFileNameChars instead.")]
public static readonly char[] InvalidPathChars;
 staticval mutable InvalidPathChars : char[]
Public Shared ReadOnly InvalidPathChars As Char() 

欄位值

Char[]
屬性

範例

下列範例示範如何使用InvalidPathChars屬性。The following 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 ] );
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}", 
    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.GetInvalidPathChars()=");
foreach (char c in Path.GetInvalidPathChars())
    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}", 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.GetInvalidPathChars()=")
Dim c As Char
For Each c In Path.GetInvalidPathChars()
    Console.Write(c)
Next 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=:

備註

不保證此方法傳回的陣列包含一組完整的檔案和目錄名稱中無效的字元。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. 例如,在 Windows 架構桌面平台上無效路徑字元可能會包括 ASCII/Unicode 字元 1 到 31,以及加上引號 (")、 小於 (<)、 大於 (>)、 管道 (|)、 退格鍵 (\b)、 null (\0) 和定位字元 (\t)。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).

警告

請勿使用InvalidPathChars如果您認為您的程式碼可能會執行相同的應用程式定義域,即不受信任的程式碼中。Do not use InvalidPathChars if you think your code might execute in the same application domain as untrusted code. InvalidPathChars 是陣列,所以其項目將會覆寫。InvalidPathChars is an array, so its elements can be overwritten. 如果不受信任的程式碼會覆寫的項目InvalidPathChars,它可能會導致您的程式碼,可能會遭到使用者的方式運作不正常。If untrusted code overwrites elements of InvalidPathChars, it might cause your code to malfunction in ways that could be exploited.

適用於

另請參閱