Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the path delimiter character in .NET?

Tags:

.net

Is there some built-in constant for the path delimiter (i.e. \ vs /)

like image 589
Jimmy Avatar asked Apr 26 '09 09:04

Jimmy


People also ask

What is the symbol for path delimiter?

The delimiting character is most commonly the slash ("/"), the backslash character ("\"), or colon (":"), though some operating systems may use a different delimiter.

What is path delimiter?

The path separator is a character commonly used by the operating system to separate individual paths in a list of paths.

What is the directory separator character?

Microsoft chose the backslash character ("\") as a directory separator, which looks similar to the slash character, though more modern version of Windows are slash-agnostic, allowing mixage of both types of slashes in a path.

What is path Directoryseparatorchar?

Provides a platform-specific character used to separate directory levels in a path string that reflects a hierarchical file system organization.


2 Answers

System.IO.Path has two readonly fields for this purpose:

  • Path.DirectorySeparatorChar: contains '\' on Windows, '/' on UNIX
  • Path.AltDirectorySeparatorChar: contains '/' on Windows, '\' on UNIX

Then there are two additional fields for the volume separator and path separator:

  • Path.VolumeSeparatorChar: the character used to separate the volume name/drive letter from the rest of tha path (':' on windows, '/' on UNIX)
  • Path.PathSeparator: the character used to separate multiple paths (';')
like image 151
M4N Avatar answered Oct 24 '22 15:10

M4N


System.IO.Path has these sort of information.

http://msdn.microsoft.com/en-us/library/system.io.path.directoryseparatorchar.aspx

like image 36
Mikko Rantanen Avatar answered Oct 24 '22 14:10

Mikko Rantanen