mirror of
https://github.com/Stone-Red-Code/AutoBackup.git
synced 2026-09-04 00:46:07 +02:00
Cleanup
This commit is contained in:
@@ -4,26 +4,24 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace AutoBackup
|
namespace AutoBackup
|
||||||
{
|
{
|
||||||
class Backup
|
internal class Backup
|
||||||
{
|
{
|
||||||
volatile public int processCount = 0;
|
volatile public int processCount = 0;
|
||||||
public List<string> currentStatus = new List<string>();
|
public List<string> currentStatus = new List<string>();
|
||||||
public bool windowVisible = false;
|
public bool windowVisible = false;
|
||||||
|
|
||||||
|
private List<string> sourceFolders = new List<string>();
|
||||||
List<string> sourceFolders = new List<string>();
|
private List<List<string>> destinationFolders = new List<List<string>>();
|
||||||
List<List<string>> destinationFolders = new List<List<string>>();
|
private List<ulong[]> optionsList = new List<ulong[]>();
|
||||||
List<ulong[]> optionsList = new List<ulong[]>();
|
private List<bool> isRunning = new List<bool>();
|
||||||
List<bool> isRunning = new List<bool>();
|
private readonly Stopwatch stopwatch;
|
||||||
readonly Stopwatch stopwatch;
|
private readonly Timer timer;
|
||||||
readonly Timer timer;
|
private bool isON = false;
|
||||||
bool isON = false;
|
|
||||||
|
|
||||||
public Backup()
|
public Backup()
|
||||||
{
|
{
|
||||||
@@ -60,9 +58,8 @@ namespace AutoBackup
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIfFilesChanged()
|
private void CheckIfFilesChanged()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OFF()
|
public void OFF()
|
||||||
@@ -141,7 +138,7 @@ namespace AutoBackup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackupFolder(int index, ulong maxBackupFolders)
|
private void BackupFolder(int index, ulong maxBackupFolders)
|
||||||
{
|
{
|
||||||
if (index < destinationFolders.Count)
|
if (index < destinationFolders.Count)
|
||||||
{
|
{
|
||||||
@@ -171,7 +168,7 @@ namespace AutoBackup
|
|||||||
{
|
{
|
||||||
MessageBox.Show(destinationFolder + " Does not exist!");
|
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--;
|
processCount--;
|
||||||
|
|
||||||
@@ -180,7 +177,7 @@ namespace AutoBackup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteDirectory(string targetDir)
|
private void DeleteDirectory(string targetDir)
|
||||||
{
|
{
|
||||||
File.SetAttributes(targetDir, FileAttributes.Normal);
|
File.SetAttributes(targetDir, FileAttributes.Normal);
|
||||||
|
|
||||||
@@ -201,7 +198,7 @@ namespace AutoBackup
|
|||||||
Directory.Delete(targetDir, false);
|
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 (isON == false) return 0;
|
||||||
if (!HasReadAccessToFolder(sourcePath)) return 0;
|
if (!HasReadAccessToFolder(sourcePath)) return 0;
|
||||||
@@ -261,7 +258,7 @@ namespace AutoBackup
|
|||||||
return filesCopied;
|
return filesCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetFileCount(string path)
|
private int GetFileCount(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -294,7 +291,6 @@ namespace AutoBackup
|
|||||||
hasAccess = false;
|
hasAccess = false;
|
||||||
}
|
}
|
||||||
return hasAccess;
|
return hasAccess;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-17
@@ -1,31 +1,27 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace AutoBackup
|
namespace AutoBackup
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
List<string> sourceFolders = new List<string>();
|
private List<string> sourceFolders = new List<string>();
|
||||||
List<List<string>> destinationFolders = new List<List<string>>();
|
private List<List<string>> destinationFolders = new List<List<string>>();
|
||||||
List<int[]> optionsList = new List<int[]>();
|
private List<int[]> optionsList = new List<int[]>();
|
||||||
readonly Backup backup;
|
private readonly Backup backup;
|
||||||
|
|
||||||
bool addSourceFolder = true;
|
private bool addSourceFolder = true;
|
||||||
bool blockWrite = false;
|
private bool blockWrite = false;
|
||||||
|
|
||||||
readonly string localApplicationDataPath;
|
private readonly string localApplicationDataPath;
|
||||||
|
|
||||||
const string AppName = "AutoBackup";
|
private const string AppName = "AutoBackup";
|
||||||
const string registrykey = "HKEY_CURRENT_USER\\" + AppName;
|
private const string registrykey = "HKEY_CURRENT_USER\\" + AppName;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
@@ -63,7 +59,7 @@ namespace AutoBackup
|
|||||||
|
|
||||||
toolTip.SetToolTip(maxBackupsNumericUpDown, "0 = no limit");
|
toolTip.SetToolTip(maxBackupsNumericUpDown, "0 = no limit");
|
||||||
|
|
||||||
statusLabel.Location = new Point(13,13);
|
statusLabel.Location = new Point(13, 13);
|
||||||
//CopyDirecotory("D:\\Test","D:\\TestCopy");
|
//CopyDirecotory("D:\\Test","D:\\TestCopy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +99,7 @@ namespace AutoBackup
|
|||||||
statusLabel.Text = textToDisplay;
|
statusLabel.Text = textToDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadFolders()
|
private void LoadFolders()
|
||||||
{
|
{
|
||||||
if (!File.Exists(localApplicationDataPath + "\\data.save"))
|
if (!File.Exists(localApplicationDataPath + "\\data.save"))
|
||||||
return;
|
return;
|
||||||
@@ -126,7 +122,7 @@ namespace AutoBackup
|
|||||||
string options = line.Substring(line.LastIndexOf(">"));
|
string options = line.Substring(line.LastIndexOf(">"));
|
||||||
line = line.Replace(options, "");
|
line = line.Replace(options, "");
|
||||||
|
|
||||||
string o3 = options.Substring(options.LastIndexOf(";")+1);
|
string o3 = options.Substring(options.LastIndexOf(";") + 1);
|
||||||
options = options.Remove(options.LastIndexOf(";"));
|
options = options.Remove(options.LastIndexOf(";"));
|
||||||
string o2 = options.Substring(options.LastIndexOf(";"));
|
string o2 = options.Substring(options.LastIndexOf(";"));
|
||||||
options = options.Replace(o2, "");
|
options = options.Replace(o2, "");
|
||||||
@@ -384,7 +380,6 @@ namespace AutoBackup
|
|||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-5
@@ -1,18 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace AutoBackup
|
namespace AutoBackup
|
||||||
{
|
{
|
||||||
static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
|
|||||||
Reference in New Issue
Block a user