Answer to Question #347831 in C# for Jen

Question #347831

You are assigned to develop a project(complete codes) in which project



manager wants following functionality.



1. Create Student Folder in C drive using Directory class.

1
Expert's answer
2022-06-06T08:58:08-0400
CreateFolder();

static void CreateFolder()
{
    try
    {
        DirectoryInfo info;
        Console.Write("Specify the path or type 'drive C' to create a Student folder: ");
        string? path = Console.ReadLine();

        switch (path)
        {
            case "drive C":
                info = Directory.CreateDirectory("C:\\Student");
                break;

            default:
                info = Directory.CreateDirectory(path + "\\Student");
                break;
        }

        Console.WriteLine("");
        Console.Write("To exit the program, press Enter.");
        Console.ReadLine();
    }
    catch (DirectoryNotFoundException e) 
    {
        Console.WriteLine("Failed to create folder.");
        CreateFolder();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS