Ready to test
This commit is contained in:
32
Helpers/HelperTooLong.cs
Normal file
32
Helpers/HelperTooLong.cs
Normal file
@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user