SoFunction
Updated on 2025-03-08

DirectoryInfo references an instance of a relative directory


        static void Main(string[] args)
        {
//Current directory
            Print(@".");
//The previous level of the current directory
            Print(@"..");
//Note: Without this command, it will return to the previous level of the current directory.
            Print(@"...");
//The previous level
            Print(@"..\..");
//The previous level of the previous level of the previous level of the previous level
            Print(@"..\..\..");
//The previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the previous level of the
            Print(@"..\..\..\..");
//Root directory
            Print(@"\");
//Subdirectory under the root directory
            Print(@"\users");
        }
        static void Print(string cmd)
        {
            ("{0}\n{1}\n", cmd, new DirectoryInfo(cmd).FullName);

        }