In the Path
class, there are two fields for directory separator chars, Path.DirectorySeparatorChar
and Path.AltDirectorySeparatorChar
. I know it's not .NET specific but OS dependent but I don't understand why there are two such characters instead of one.
For example there is only one Path.VolumeSeparatorChar
.
Path Separator The path separator is a character commonly used by the operating system to separate individual paths in a list of paths. 3.1. Get the Path Separator
The file separator is the character used to separate the directory names that make up the path to a specific location. 2.1. Get the File Separator There are several ways to get the file separator in Java. We can get the separator as a String using File.separator: We can also get this separator as a char with File.separatorChar:
Provides a platform-specific alternate character used to separate directory levels in a path string that reflects a hierarchical file system organization. You can use alt separator in your path strings the same way as you use normal separator. Like this:
With DOS 3.0 the SWITCHAR= option got removed fom CONFIG.SYS, but the syscalls are still availabe up to today.
The value of this field is a backslash ('\') on UNIX, and a slash ('/') on Windows and Macintosh operating systems.
From MSDN system.io.path.altdirectoryseparatorchar
As for Path.VolumeSeparatorChar :
The value of this field is a colon (:) on Windows and Macintosh, and a slash (/) on UNIX operating systems. This is most useful for parsing paths such as "c:\windows" or "MacVolume:System Folder".
However note that on UNIX there is no volume separator as devices are mounted on the filesystem at a mount point, which is a directory. So one really accesses files with directory separators, therefore causing no ambiguity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With