共用方式為


Path.InvalidPathChars 欄位

定義

警告

Please use GetInvalidPathChars or GetInvalidFileNameChars instead.

警告

Path.InvalidPathChars has been deprecated. Use GetInvalidPathChars or GetInvalidFileNameChars instead.

提供字元的平台特定陣列,這些字元不可以在傳遞給 Path 類別成員的路徑字串引數中指定。

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

欄位值

Char[]
屬性

範例

下列範例示範屬性的使用 InvalidPathChars

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=:

備註

從這個方法傳回的陣列不保證包含檔案和目錄名稱中無效的完整字元集。 一組無效字元可能會因檔案系統而異。 GetInvalidPathChars()請參閱備註,以瞭解此欄位所傳回的字元集。

警告

如果您認為程式代碼可能會在與不受信任的程式代碼相同的應用程式域中執行,請勿使用 InvalidPathCharsInvalidPathChars 是陣列,因此可以覆寫其元素。 如果不受信任的程式代碼覆寫 的 InvalidPathChars元素,可能會導致程式代碼因可能遭到惡意探索的方式而故障。

適用於

另請參閱