From b340810c11ad11b4db4f9ba4618da1b62fa4555e Mon Sep 17 00:00:00 2001 From: Daniel Winter Date: Tue, 3 May 2016 09:28:51 +0200 Subject: [PATCH] fixed the dll missing error and checking if last change is null --- PraiseTheSave.sln | 1 + PraiseTheSave/FodyWeavers.xml | 5 +++++ PraiseTheSave/Form1.cs | 32 +++++++++++++++++++++++++++--- PraiseTheSave/PraiseTheSave.csproj | 12 ++++++++++- PraiseTheSave/packages.config | 2 ++ 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 PraiseTheSave/FodyWeavers.xml diff --git a/PraiseTheSave.sln b/PraiseTheSave.sln index 0d11323..dbf27e5 100644 --- a/PraiseTheSave.sln +++ b/PraiseTheSave.sln @@ -15,6 +15,7 @@ Global {889E2248-74DA-4DC4-B802-0D64E34F0748}.Debug|Any CPU.Build.0 = Debug|Any CPU {889E2248-74DA-4DC4-B802-0D64E34F0748}.Release|Any CPU.ActiveCfg = Release|Any CPU {889E2248-74DA-4DC4-B802-0D64E34F0748}.Release|Any CPU.Build.0 = Release|Any CPU + {889E2248-74DA-4DC4-B802-0D64E34F0748}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PraiseTheSave/FodyWeavers.xml b/PraiseTheSave/FodyWeavers.xml new file mode 100644 index 0000000..2e6d4a7 --- /dev/null +++ b/PraiseTheSave/FodyWeavers.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/PraiseTheSave/Form1.cs b/PraiseTheSave/Form1.cs index 89c21ce..f612690 100644 --- a/PraiseTheSave/Form1.cs +++ b/PraiseTheSave/Form1.cs @@ -68,6 +68,11 @@ private FileInfo getOldestFileInDir(DirectoryInfo dir) return dir.GetFiles().OrderByDescending(f => f.LastWriteTime).Last(); } + public bool IsDirectoryEmpty(string path) + { + return !Directory.EnumerateFileSystemEntries(path).Any(); + } + private void Form1_Load(object sender, EventArgs e) { @@ -195,7 +200,14 @@ public void doBackup(object sender, EventArgs e) if (!Directory.Exists(ds1destination)) Directory.CreateDirectory(ds1destination); - if (PraiseTheSave.Properties.Settings.Default.LastDS1Change != File.GetLastWriteTime(getLatestFileInDir(new DirectoryInfo(ds1save)).FullName)) + DateTime? lastDS1Change = PraiseTheSave.Properties.Settings.Default.LastDS1Change; + if ( + IsDirectoryEmpty(ds1destination) + || + !lastDS1Change.HasValue + || + PraiseTheSave.Properties.Settings.Default.LastDS1Change != File.GetLastWriteTime(getLatestFileInDir(new DirectoryInfo(ds1save)).FullName) + ) { while (PraiseTheSave.Properties.Settings.Default.SaveAmount <= Directory.GetFiles(ds1destination).Length) { @@ -220,7 +232,14 @@ public void doBackup(object sender, EventArgs e) if (!Directory.Exists(ds2destination)) Directory.CreateDirectory(ds2destination); - if (PraiseTheSave.Properties.Settings.Default.LastDS2Change != File.GetLastWriteTime(getLatestFileInDir(new DirectoryInfo(ds2save)).FullName)) + DateTime? lastDS2Change = PraiseTheSave.Properties.Settings.Default.LastDS2Change; + if ( + IsDirectoryEmpty(ds2destination) + || + !lastDS2Change.HasValue + || + PraiseTheSave.Properties.Settings.Default.LastDS2Change != File.GetLastWriteTime(getLatestFileInDir(new DirectoryInfo(ds2save)).FullName) + ) { while (PraiseTheSave.Properties.Settings.Default.SaveAmount <= Directory.GetFiles(ds2destination).Length) @@ -246,7 +265,14 @@ public void doBackup(object sender, EventArgs e) if (!Directory.Exists(ds3destination)) Directory.CreateDirectory(ds3destination); - if (PraiseTheSave.Properties.Settings.Default.LastDS3Change != File.GetLastWriteTime(getLatestFileInDir(new DirectoryInfo(ds3save)).FullName)) + DateTime? lastDS3Change = PraiseTheSave.Properties.Settings.Default.LastDS3Change; + if ( + IsDirectoryEmpty(ds3destination) + || + !lastDS3Change.HasValue + || + PraiseTheSave.Properties.Settings.Default.LastDS3Change != File.GetLastWriteTime(getLatestFileInDir(new DirectoryInfo(ds3save)).FullName) + ) { while (PraiseTheSave.Properties.Settings.Default.SaveAmount <= Directory.GetFiles(ds3destination).Length) diff --git a/PraiseTheSave/PraiseTheSave.csproj b/PraiseTheSave/PraiseTheSave.csproj index 1c804c1..5809a04 100644 --- a/PraiseTheSave/PraiseTheSave.csproj +++ b/PraiseTheSave/PraiseTheSave.csproj @@ -26,11 +26,13 @@ https://github.com/lucidlemon/PraiseTheSave/ true publish.htm - 1 + 2 1.0.0.%2a false true true + + AnyCPU @@ -133,9 +135,17 @@ + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +