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?
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"
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).
It's read only, you can't change it. A Path represents a path that the operating system running the framework and your application understands. If you use any other value, the OS won't understand it. There's no OS in the world which understands "a//b//c" paths. But you can have arbitrary strings which contain paths like that, except they won't be OS-understandable file paths, and you can call them something else.
It's equal to Path.PathSeparator
, it's better to use this,
精彩评论