IDirectory first pass
This commit is contained in:
@ -38,6 +38,7 @@ public partial class UnitTestCalculations
|
||||
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||
@ -368,4 +369,40 @@ public partial class UnitTestCalculations
|
||||
Assert.IsTrue(check == 200);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMovingFiles()
|
||||
{
|
||||
char directory;
|
||||
string fileName;
|
||||
string checkFile;
|
||||
int directoryIndex;
|
||||
string checkDirectory;
|
||||
List<string> collection = new();
|
||||
string source = "C:/1234567890123456789";
|
||||
if (Directory.Exists(source))
|
||||
{
|
||||
for (int i = 0; i < 11; i++)
|
||||
{
|
||||
if (i == 10)
|
||||
checkDirectory = Path.Combine(source, "-");
|
||||
else
|
||||
checkDirectory = Path.Combine(source, i.ToString());
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
collection.Add(checkDirectory);
|
||||
}
|
||||
Dictionary<string, string[]> jsonGroups = new() { { "{}", collection.ToArray() } };
|
||||
foreach (string file in Directory.GetFiles(source))
|
||||
{
|
||||
fileName = Path.GetFileName(file);
|
||||
directory = IDirectory.GetDirectory(fileName);
|
||||
directoryIndex = IDirectory.GetDirectory(directory);
|
||||
checkFile = Path.Combine(jsonGroups["{}"][directoryIndex], fileName);
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user