Код: Выделить всё
void rmdir(string input)
{
try
{
if (string.IsNullOrEmpty(input))
{
Console.WriteLine("Error: input cannot be empty.");
return;
}
string fixed_input = input.Substring(6).Trim();
if (string.IsNullOrEmpty(fixed_input))
{
Console.WriteLine("Error: Directory name cannot be empty.");
return;
}
string path = current_path + fixed_input;
if (!Directory.Exists(path))
{
Console.WriteLine("Error: Directory does NOT exist.");
return;
}
if (Directory.GetFileSystemEntries(path).Length > 0)
{
Console.WriteLine("Error: Directory isn't empty.");
return;
}
Directory.Delete(path);
Console.WriteLine($"Directory '{fixed_input} deleted successfully.");
}
catch (Exception e)
{
Console.WriteLine("Error occurred: " + e.Message);
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... n-cosmos-c
Мобильная версия