Did cleanup of code base for .NET core version.
This commit is contained in:
2
.idea/.gitignore
generated
vendored
Normal file
2
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# Default ignored files
|
||||
/.idea.OneDriveArchiver/.idea/workspace.xml
|
||||
@@ -1,6 +1,8 @@
|
||||
#region Using Statements
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace OneDriveArchiver
|
||||
@@ -19,10 +21,7 @@ namespace OneDriveArchiver
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
throw new ArgumentException("filename cannot be null.");
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename)) throw new ArgumentException("filename cannot be null.");
|
||||
|
||||
// do a check if the file is empty...
|
||||
var fi = new FileInfo(filename);
|
||||
@@ -32,6 +31,7 @@ namespace OneDriveArchiver
|
||||
File.Delete(filename);
|
||||
return;
|
||||
}
|
||||
|
||||
var dateModified = File.GetLastWriteTime(filename);
|
||||
var fileMonth = dateModified.Month.ToString("D2");
|
||||
var fileYear = dateModified.Year.ToString();
|
||||
@@ -42,15 +42,9 @@ namespace OneDriveArchiver
|
||||
// start with parent year folder...
|
||||
var fullYearFolderPath = Path.Combine(basePath ?? throw new InvalidOperationException(), fileYear);
|
||||
var fullMonthFolderPath = Path.Combine(Path.Combine(basePath, fileYear), fileMonth);
|
||||
if (!Directory.Exists(fullYearFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(fullYearFolderPath);
|
||||
}
|
||||
if (!Directory.Exists(fullYearFolderPath)) Directory.CreateDirectory(fullYearFolderPath);
|
||||
// then month...
|
||||
if (!Directory.Exists(fullMonthFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(fullMonthFolderPath);
|
||||
}
|
||||
if (!Directory.Exists(fullMonthFolderPath)) Directory.CreateDirectory(fullMonthFolderPath);
|
||||
|
||||
// then move the file...
|
||||
File.Move(filename, Path.Combine(fullMonthFolderPath, fileNameWithOutPath));
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#region Using Statements
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace OneDriveArchiver
|
||||
{
|
||||
class Program
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
// handle improper arguments
|
||||
Console.WriteLine("OneDriverArchiver: Please specify a directory with files mapped to a Microsoft OneDrive folder.");
|
||||
Console.WriteLine(
|
||||
"OneDriverArchiver: Please specify a directory with files mapped to a Microsoft OneDrive folder.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -49,7 +52,8 @@ namespace OneDriveArchiver
|
||||
var endProcessingTime = DateTime.Now;
|
||||
var processingTime = endProcessingTime - startUpTime;
|
||||
|
||||
Console.WriteLine($"OneDriverArchiver: Processing completed.\nProcessing time = {processingTime}\nNumber of files = {filesToProcess.Length}.");
|
||||
Console.WriteLine(
|
||||
$"OneDriverArchiver: Processing completed.\nProcessing time = {processingTime}\nNumber of files = {filesToProcess.Length}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user