C# @"../.." 在路径中是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9389266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does @"../.." mean in a path?
提问by Xel
I am following this tutorialfrom MSDN.
我正在关注MSDN 上的本教程。
There's something I saw in the code that I can't understand
我在代码中看到了一些我无法理解的东西
private void PopulateTreeView()
{
TreeNode rootNode;
DirectoryInfo info = new DirectoryInfo(@"../.."); // <- What does @"../.." mean?
if (info.Exists)
{
rootNode = new TreeNode(info.Name);
rootNode.Tag = info;
GetDirectories(info.GetDirectories(), rootNode);
treeView1.Nodes.Add(rootNode);
}
}
采纳答案by manojlds
@is for verbatim string, so that the string is treated as is. Especially useful for paths that have a \which might be treated as escape characters ( like \n)
@用于逐字字符串,以便按原样处理字符串。对于具有\可能被视为转义字符(如\n)的路径特别有用
../..is relative path, in this case, two levels up. ..represents parent of current directory and so on.
../..是相对路径,在这种情况下,向上两级。..代表当前目录的父目录等等。
回答by shift66
..is the container directory. So ../..means "up" twice.
For example if your current directory is C:/projects/a/b/cthen ../..will be C:/projects/a
..是容器目录。所以../..意思是“向上”两次。
例如,如果您的当前目录中C:/projects/a/b/c,然后../..将C:/projects/a
回答by dasblinkenlight
new DirectoryInfo(@"../..")means "a directory two levels above the current one".
new DirectoryInfo(@"../..")表示“比当前目录高两级的目录”。
The @denotes a verbatim string literal.
该@表示逐字字符串。
回答by Akash das
example E:\Software\file\folder
示例 E:\Software\file\folder
/ is the root of the current drive. ./ is the current director. ../ is the parent of the current directory. that is ->E:\ ../.. is relative path, in this case, two levels up. to get folder just write "../../folder"
/ 是当前驱动器的根目录。./ 是现任导演。../ 是当前目录的父目录。即 ->E:\ ../.. 是相对路径,在这种情况下,向上两级。获取文件夹只需写“../../folder”

