From 086dd757a3aae39e0dad8bf36dcae56d49b943d6 Mon Sep 17 00:00:00 2001
From: Stone-Red-Code <56473591+Stone-Red-Code@users.noreply.github.com>
Date: Wed, 24 Feb 2021 22:34:36 +0100
Subject: [PATCH] Cleanup
---
App.config | 2 +-
Backup.cs | 38 +++++++++++++++++---------------------
MainForm.cs | 33 ++++++++++++++-------------------
Program.cs | 9 +++------
Properties/AssemblyInfo.cs | 3 +--
5 files changed, 36 insertions(+), 49 deletions(-)
diff --git a/App.config b/App.config
index 56efbc7..ffaf540 100644
--- a/App.config
+++ b/App.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/Backup.cs b/Backup.cs
index 68cb251..1de3c6e 100644
--- a/Backup.cs
+++ b/Backup.cs
@@ -4,26 +4,24 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
-using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoBackup
{
- class Backup
+ internal class Backup
{
volatile public int processCount = 0;
public List currentStatus = new List();
public bool windowVisible = false;
-
- List sourceFolders = new List();
- List> destinationFolders = new List>();
- List optionsList = new List();
- List isRunning = new List();
- readonly Stopwatch stopwatch;
- readonly Timer timer;
- bool isON = false;
+ private List sourceFolders = new List();
+ private List> destinationFolders = new List>();
+ private List optionsList = new List();
+ private List isRunning = new List();
+ private readonly Stopwatch stopwatch;
+ private readonly Timer timer;
+ private bool isON = false;
public Backup()
{
@@ -60,9 +58,8 @@ namespace AutoBackup
*/
}
- void CheckIfFilesChanged()
+ private void CheckIfFilesChanged()
{
-
}
public void OFF()
@@ -141,14 +138,14 @@ namespace AutoBackup
}
}
- void BackupFolder(int index, ulong maxBackupFolders)
+ private void BackupFolder(int index, ulong maxBackupFolders)
{
if (index < destinationFolders.Count)
{
Task.Run(() =>
{
processCount++;
-
+
foreach (string destinationFolder in destinationFolders[index])
{
if (Directory.Exists(destinationFolder))
@@ -171,7 +168,7 @@ namespace AutoBackup
{
MessageBox.Show(destinationFolder + " Does not exist!");
}
- CopyDirecotory(sourceFolders[index], destinationFolder + "\\Backup " + DateTime.Now.ToString().Replace(":", "-").Replace("/",".").Replace("\\","."), index, GetFileCount(sourceFolders[index]));
+ CopyDirecotory(sourceFolders[index], destinationFolder + "\\Backup " + DateTime.Now.ToString().Replace(":", "-").Replace("/", ".").Replace("\\", "."), index, GetFileCount(sourceFolders[index]));
}
processCount--;
@@ -180,7 +177,7 @@ namespace AutoBackup
}
}
- void DeleteDirectory(string targetDir)
+ private void DeleteDirectory(string targetDir)
{
File.SetAttributes(targetDir, FileAttributes.Normal);
@@ -201,7 +198,7 @@ namespace AutoBackup
Directory.Delete(targetDir, false);
}
- int CopyDirecotory(string sourcePath, string destinationPath, int index, int fileCount, int filesCopied = 0)
+ private int CopyDirecotory(string sourcePath, string destinationPath, int index, int fileCount, int filesCopied = 0)
{
if (isON == false) return 0;
if (!HasReadAccessToFolder(sourcePath)) return 0;
@@ -218,7 +215,7 @@ namespace AutoBackup
foreach (string file in Directory.GetFiles(sourcePath))
{
if (isON == false) return 0;
-
+
if (windowVisible)
{
if (fileCount > 0)
@@ -261,7 +258,7 @@ namespace AutoBackup
return filesCopied;
}
- int GetFileCount(string path)
+ private int GetFileCount(string path)
{
try
{
@@ -294,7 +291,6 @@ namespace AutoBackup
hasAccess = false;
}
return hasAccess;
-
}
}
-}
+}
\ No newline at end of file
diff --git a/MainForm.cs b/MainForm.cs
index 12db87a..914abb2 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -1,31 +1,27 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoBackup
{
public partial class MainForm : Form
{
- List sourceFolders = new List();
- List> destinationFolders = new List>();
- List optionsList = new List();
- readonly Backup backup;
+ private List sourceFolders = new List();
+ private List> destinationFolders = new List>();
+ private List optionsList = new List();
+ private readonly Backup backup;
- bool addSourceFolder = true;
- bool blockWrite = false;
+ private bool addSourceFolder = true;
+ private bool blockWrite = false;
- readonly string localApplicationDataPath;
+ private readonly string localApplicationDataPath;
- const string AppName = "AutoBackup";
- const string registrykey = "HKEY_CURRENT_USER\\" + AppName;
+ private const string AppName = "AutoBackup";
+ private const string registrykey = "HKEY_CURRENT_USER\\" + AppName;
public MainForm()
{
@@ -63,7 +59,7 @@ namespace AutoBackup
toolTip.SetToolTip(maxBackupsNumericUpDown, "0 = no limit");
- statusLabel.Location = new Point(13,13);
+ statusLabel.Location = new Point(13, 13);
//CopyDirecotory("D:\\Test","D:\\TestCopy");
}
@@ -103,7 +99,7 @@ namespace AutoBackup
statusLabel.Text = textToDisplay;
}
- void LoadFolders()
+ private void LoadFolders()
{
if (!File.Exists(localApplicationDataPath + "\\data.save"))
return;
@@ -126,7 +122,7 @@ namespace AutoBackup
string options = line.Substring(line.LastIndexOf(">"));
line = line.Replace(options, "");
- string o3 = options.Substring(options.LastIndexOf(";")+1);
+ string o3 = options.Substring(options.LastIndexOf(";") + 1);
options = options.Remove(options.LastIndexOf(";"));
string o2 = options.Substring(options.LastIndexOf(";"));
options = options.Replace(o2, "");
@@ -135,7 +131,7 @@ namespace AutoBackup
optionsList[index][2] = int.Parse(o3);
optionsList[index][1] = int.Parse(o2.Replace(";", ""));
optionsList[index][0] = int.Parse(o1);
-
+
while (line.Contains("|"))
{
string folder = line.Substring(line.LastIndexOf("|"));
@@ -384,7 +380,6 @@ namespace AutoBackup
private void MainForm_Load(object sender, EventArgs e)
{
-
}
}
-}
+}
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index bb64050..8ccd66e 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,22 +1,19 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoBackup
{
- static class Program
+ internal static class Program
{
///
/// Der Haupteinstiegspunkt für die Anwendung.
///
[STAThread]
- static void Main()
+ private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
-}
+}
\ No newline at end of file
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index 4ec782c..2f16892 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
@@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file