0% found this document useful (0 votes)
7 views

Program.cs

This C# program allows users to create or delete a temporary folder named 'Hi' on their desktop. Users can select options to create the folder or revert (delete) it using keyboard inputs. The program runs in a loop until a valid option is selected and then prompts the user to close the window.

Uploaded by

the.mico.102
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Program.cs

This C# program allows users to create or delete a temporary folder named 'Hi' on their desktop. Users can select options to create the folder or revert (delete) it using keyboard inputs. The program runs in a loop until a valid option is selected and then prompts the user to close the window.

Uploaded by

the.mico.102
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System;

namespace Program
{
class FileManager
{
static void Main()
{
//variables
string Desktop =
Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string createFolder = Path.Combine(Desktop, "Hi");

//run code
Console.WriteLine("Please select the following options:\n1. Create a
temporary folder\n2. Revert");
ConsoleKeyInfo selectedOption;
while (true)
{
selectedOption = Console.ReadKey(true);

switch (selectedOption.Key)
{
case ConsoleKey.D1:
case ConsoleKey.NumPad1:
Directory.CreateDirectory(createFolder);
Console.WriteLine("Folder Created at " + Desktop);
break;

case ConsoleKey.D2:
case ConsoleKey.NumPad2:
if (Directory.Exists(createFolder))
{
Directory.Delete(createFolder);
Console.WriteLine("Folder Deleted");
}
else
{
Console.WriteLine("No folder created by this program
was detected");
}
break;

default:
Console.WriteLine("No option selected.");
continue;
}
break;
}
Console.WriteLine("\nPress Any Key to Close this Window . . .");
Console.ReadKey(true);
}
}
}

You might also like