32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
namespace File_Folder_Helper.Helpers;
|
|
|
|
internal static class HelperTooLong
|
|
{
|
|
|
|
internal static void TooLong(string workingDirectory, bool delete)
|
|
{
|
|
string[] files;
|
|
string destination;
|
|
string? parentDirectory;
|
|
string[] directories = Directory.GetDirectories(workingDirectory, "*", SearchOption.TopDirectoryOnly);
|
|
for (int i = 0; i < directories.Length; i++)
|
|
{
|
|
if (delete)
|
|
{
|
|
Directory.Delete(directories[i], recursive: true);
|
|
break;
|
|
}
|
|
files = Directory.GetFiles(directories[i], "*", SearchOption.TopDirectoryOnly);
|
|
for (int f = 0; f < files.Length; f++)
|
|
File.Delete(files[f]);
|
|
parentDirectory = Path.GetDirectoryName(directories[i]);
|
|
if (string.IsNullOrEmpty(parentDirectory))
|
|
continue;
|
|
destination = Path.Combine(parentDirectory, i.ToString());
|
|
if (Path.GetFileName(directories[i]).Length > 3)
|
|
Directory.Move(directories[i], destination);
|
|
TooLong(destination, delete);
|
|
}
|
|
}
|
|
|
|
} |