Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# char "//" path separator

Tags:

c#

separator

Is there possible to use char "//" another there I did it? I looked for in Path, but I can't find it.

  string separator = "//"; 

I mean '/'.

I used:

static string sep = System.IO.Path.PathSeparator.ToString(); 

but it returns: ';'. Why?

like image 269
Catherine Avatar asked Jan 04 '11 19:01

Catherine


People also ask

What C is used for?

C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Why is C named so?

Quote from wikipedia: "A successor to the programming language B, C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to construct utilities running on Unix." The creators want that everyone "see" his language. So he named it "C".

What is C of computer?

" " C is a computer programming language. That means that you can use C to create lists of instructions for a computer to follow. C is one of thousands of programming languages currently in use.


2 Answers

Path.DirectorySeparatorChar gives you the character used to separate directories in a path, i.e. you use it in paths.

Path.PathSeparator gives you the character used to separate paths in environment variables, i.e. you use it between paths.

For example, your system's PATH environment variable will typically list multiple paths where the OS will look for applications to run.

On Windows, Path.PathSeparator is ;, and Path.DirectorySeparatorChar is \. Two paths would be stored in an environment variable like this:

set PATH="C:\first\path;C:\second\path" 
like image 74
Ergwun Avatar answered Sep 22 '22 08:09

Ergwun


Is System.IO.Path.PathSeparator what you're actually looking for? There's also .DirectorySeparatorChar and others. See the System.IO.Path class under "Fields".

To elaborate, a path separator is used to concatenate multiple full paths together (think the PATH environmental variable). It sounds like you're after the directory separator, which is used within a single path to split out folders/ files. (In windows it's commonly \, and / basically elsewhere).

like image 43
Brad Christie Avatar answered Sep 24 '22 08:09

Brad Christie