I am following this tutorial from 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);
}
}
. means it's the current directory. / is normally used in paths to show the structure of files and folders. \\ is referring to \ (used double because \ is a special character) which is same as / but used differently depending on the OS.
A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy.
The double asterisks are placeholders or instructions to the recursive interpreter to go through the files and folders. It is a simple, recursive wildcard while only one asterisk means all without recursion.
A standard DOS path can consist of three components: A volume or drive letter followed by the volume separator ( : ). A directory name. The directory separator character separates subdirectories within the nested directory hierarchy.
@
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
)
../..
is relative path, in this case, two levels up. ..
represents parent of current directory and so on.
..
is the container directory. So ../..
means "up" twice.
For example if your current directory is C:/projects/a/b/c
then ../..
will be C:/projects/a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With