Freigeben über


Path.DirectorySeparatorChar-Feld

Stellt ein plattformspezifisches Zeichen bereit, das zur Trennung von Verzeichnisebenen in einer Pfadzeichenfolge verwendet wird und eine hierarchische Dateisystemorganisation wiedergibt.

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared ReadOnly DirectorySeparatorChar As Char
'Usage
Dim value As Char

value = Path.DirectorySeparatorChar
public static readonly char DirectorySeparatorChar
public:
static initonly wchar_t DirectorySeparatorChar
public static final char DirectorySeparatorChar
public static final var DirectorySeparatorChar : char

Hinweise

Das in diesem Feld gespeicherte Zeichen darf nicht in InvalidPathChars vorhanden sein. AltDirectorySeparatorChar und DirectorySeparatorChar sind beide zur Trennung von Verzeichnisebenen in einer Pfadzeichenfolge gültig.

Der Wert dieses Felds ist unter UNIX ein Schrägstrich ("/") und unter den Betriebssystemen Windows und Macintosh ein umgekehrter Schrägstrich ("\").

Beispiel

Im folgenden Codebeispiel wird die Verwendung des DirectorySeparatorChar-Felds veranschaulicht.

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

' 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.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}", (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();
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();

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Path-Klasse
Path-Member
System.IO-Namespace

Weitere Ressourcen

Datei- und Stream-E/A
Gewusst wie: Lesen aus einer Textdatei
Gewusst wie: Schreiben von Text in eine Datei