What Does @". ./. ." Mean in a Path?

What Does @". ./. ." Mean in a Path?

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);
        }
    }
2

4 Answers

@ 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

2

new DirectoryInfo(@"../..") means "a directory two levels above the current one".

The @ denotes a verbatim string literal.

example 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"

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.