Using Path Of Created Sub Directory C# with Example



Using Path Of Created Sub Directory C# with Example

 using System.IO;
using System;

namespace CSharpFilesAndStreams
{
    class Program
    {
        static void Main(string[] args)
        {
            FunWithDirectoryType();
        }

		static void FunWithDirectoryType()
		{
			// List all drives on current computer.
			string[] drives = Directory.GetLogicalDrives();
			Console.WriteLine("Here are your drives:");

			foreach (string s in drives)
				Console.WriteLine("--> {0} ", s);
			
			// Delete what was created.
			Console.WriteLine("Press Enter to delete directories");
			Console.ReadLine();
			try
			{
				Directory.Delete(@"C:\MyFolder");
				// The second parameter specifies whether you wish to destroy any subdirectories.
				Directory.Delete(@"C:\MyFolder2", true);
			}
			catch (IOException e)
			{
			Console.WriteLine(e.Message);
			}
		}
	}
}	 

0 Comment's

Comment Form

Submit Comment