Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there two directory separator chars?

Tags:

c#

.net

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.

like image 973
wojtek Avatar asked Jun 18 '18 08:06

wojtek


People also ask

What is path separator in Linux?

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

How to get file separator in Java?

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:

What is Alt separator in path strings?

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:

What happened to SwitChar= option in DOS?

With DOS 3.0 the SWITCHAR= option got removed fom CONFIG.SYS, but the syscalls are still availabe up to today.


1 Answers

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.

like image 107
Attersson Avatar answered Oct 27 '22 04:10

Attersson