Create directory, check files and RecycleOption
This commit is contained in:
@ -61,9 +61,11 @@ public class DeleteByDistinct
|
||||
fileInfo = new(file);
|
||||
if (fileInfo.Length < 100)
|
||||
continue;
|
||||
checkLength = fileInfo.Length;
|
||||
if (appSettings.RecycleOption)
|
||||
checkLength = 1;
|
||||
else
|
||||
checkLength = fileInfo.Length;
|
||||
// checkLength = (long)Math.Round((double)(fileInfo.Length / 1000));
|
||||
// checkLength = 1;
|
||||
if (!fileSizeToCollection.TryGetValue(checkLength, out fileTicksToNames))
|
||||
{
|
||||
fileSizeToCollection.Add(checkLength, new());
|
||||
@ -76,9 +78,11 @@ public class DeleteByDistinct
|
||||
// if (!fileTicksToNames.TryGetValue(fileInfo.LastWriteTime.Ticks, out fileNames))
|
||||
// throw new Exception();
|
||||
// }
|
||||
checkTicks = new DateTime(ticks).Ticks;
|
||||
if (appSettings.RecycleOption)
|
||||
checkTicks = 1;
|
||||
else
|
||||
checkTicks = new DateTime(ticks).Ticks;
|
||||
// checkTicks = new DateTime(fileInfo.LastWriteTime.Year, fileInfo.LastWriteTime.Month, fileInfo.LastWriteTime.Day).Ticks;
|
||||
// checkTicks = 1;
|
||||
if (!fileTicksToNames.TryGetValue(checkTicks, out fileNames))
|
||||
{
|
||||
fileTicksToNames.Add(checkTicks, new());
|
||||
@ -113,9 +117,18 @@ public class DeleteByDistinct
|
||||
{
|
||||
foreach (string file in deletedFiles)
|
||||
{
|
||||
try
|
||||
{ File.Delete(file); }
|
||||
catch (Exception) { }
|
||||
if (!appSettings.RecycleOption)
|
||||
{
|
||||
try
|
||||
{ File.Delete(file); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{ Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(file, Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs, Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
message = $") Looking for empty directories from <{directory}> - {totalSeconds} total second(s)";
|
||||
|
Reference in New Issue
Block a user