A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C# program to delete an empty and a non-empty directory
Q:

C# program to delete an empty and a non-empty directory

0

C# program to delete an empty and a non-empty directory

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Delete Empty directory (Empty1)");
            Directory.Delete("D:/Empty1");

            Console.WriteLine("Delete Empty directory (Empty2)");
            Directory.Delete("D:/Empty2",false);

            Console.WriteLine("Delete Non-Empty directory (India)");
            Directory.Delete("D:/India",true);
        }
    }
}

Output

Delete Empty directory (Empty1)
Delete Empty directory (Empty2)
Delete Non-Empty directory (India)

Note: In above program, we need to remember, when we use "Directory" class, System.IO namespace must be included in the program.

In this program, method is overloaded, to allow or deny recursive deletion.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now