C # char "//" path separator

Is it possible to use char "//" another where I did it? I searched the Way, but I cannot find it.

string separato = "//"; 

I mean '/'.

I used: static string sep = System.IO.Path.PathSeparator.ToString (); but it returns: ';'. Why?

+8
c # separator
source share
4 answers

Is System.IO.Path.PathSeparator , what do you want for? There is also .DirectorySeparatorChar and others. See System.IO.Path in the Fields section.

+6
source share

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

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

For example, your system PATH variable will usually indicate several paths in which the OS will look for applications to run.

In Windows Path.PathSeparator is ; , and Path.DirectorySeparatorChar - \ , two paths will be stored in an environment variable like this:

 set PATH="C:\first\path;C:\second\path" 
+25
source share

This is just a read, you cannot change it. A path is a path that an operating system understands that uses the framework and your application. If you use any other value, the OS will not understand it. There are no OSs in the world that understand the paths "a // b // c". But you can have arbitrary strings containing such paths, except that they will not be file paths that are understandable to the OS, and you can call them something else.

0
source share

It is equal to Path.PathSeparator , it is better to use this,

-one
source share

Source: https://habr.com/ru/post/650684/


All Articles