Udostępnij przez


Path.InvalidPathChars Pole

Definicja

Przestroga

Please use GetInvalidPathChars or GetInvalidFileNameChars instead.

Przestroga

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

Zawiera tablicę znaków specyficzną dla platformy, której nie można określić w argumentach ciągu ścieżki przekazywanych do składowych Path klasy.

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() 

Wartość pola

Char[]
Atrybuty

Przykłady

W poniższym przykładzie pokazano użycie InvalidPathChars właściwości .

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

Uwagi

Tablica zwrócona z tej metody nie ma gwarancji, że zawiera pełny zestaw znaków, które są nieprawidłowe w nazwach plików i katalogów. Pełny zestaw nieprawidłowych znaków może się różnić w zależności od systemu plików. Zapoznaj się z GetInvalidPathChars() uwagami, aby dowiedzieć się, jaki jest zestaw znaków zwracanych przez to pole.

Przestroga

Nie należy używać InvalidPathChars , jeśli uważasz, że kod może zostać wykonany w tej samej domenie aplikacji co niezaufany kod. InvalidPathChars jest tablicą, więc jej elementy można zastąpić. Jeśli niezaufany kod zastępuje elementy InvalidPathCharselementu , może to spowodować nieprawidłowe działanie kodu w sposób, który można wykorzystać.

Dotyczy

Zobacz też