This commit is contained in:
Stone-Red-Code
2021-02-24 22:34:36 +01:00
parent ccae85b151
commit 086dd757a3
5 changed files with 36 additions and 49 deletions
+14 -18
View File
@@ -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<string> currentStatus = new List<string>();
public bool windowVisible = false;
List<string> sourceFolders = new List<string>();
List<List<string>> destinationFolders = new List<List<string>>();
List<ulong[]> optionsList = new List<ulong[]>();
List<bool> isRunning = new List<bool>();
readonly Stopwatch stopwatch;
readonly Timer timer;
bool isON = false;
private List<string> sourceFolders = new List<string>();
private List<List<string>> destinationFolders = new List<List<string>>();
private List<ulong[]> optionsList = new List<ulong[]>();
private List<bool> isRunning = new List<bool>();
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,7 +138,7 @@ namespace AutoBackup
}
}
void BackupFolder(int index, ulong maxBackupFolders)
private void BackupFolder(int index, ulong maxBackupFolders)
{
if (index < destinationFolders.Count)
{
@@ -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;
@@ -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;
}
}
}
+12 -17
View File
@@ -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<string> sourceFolders = new List<string>();
List<List<string>> destinationFolders = new List<List<string>>();
List<int[]> optionsList = new List<int[]>();
readonly Backup backup;
private List<string> sourceFolders = new List<string>();
private List<List<string>> destinationFolders = new List<List<string>>();
private List<int[]> optionsList = new List<int[]>();
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, "");
@@ -384,7 +380,6 @@ namespace AutoBackup
private void MainForm_Load(object sender, EventArgs e)
{
}
}
}
+2 -5
View File
@@ -1,18 +1,15 @@
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
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
-1
View File
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden