diff --git a/.vs/DeleteFileFolder.git/FileContentIndex/a4c052dc-0fd0-4671-9802-c13bd0f8dfa9.vsidx b/.vs/DeleteFileFolder.git/FileContentIndex/a4c052dc-0fd0-4671-9802-c13bd0f8dfa9.vsidx new file mode 100644 index 0000000..a13edb5 Binary files /dev/null and b/.vs/DeleteFileFolder.git/FileContentIndex/a4c052dc-0fd0-4671-9802-c13bd0f8dfa9.vsidx differ diff --git a/.vs/DeleteFileFolder.git/FileContentIndex/read.lock b/.vs/DeleteFileFolder.git/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/DeleteFileFolder.git/v17/.suo b/.vs/DeleteFileFolder.git/v17/.suo index 2473de1..f52625e 100644 Binary files a/.vs/DeleteFileFolder.git/v17/.suo and b/.vs/DeleteFileFolder.git/v17/.suo differ diff --git a/DeleteFileFolder/DeleteFileFolder.cs b/DeleteFileFolder/DeleteFileFolder.cs index d7e3e40..b41b315 100644 --- a/DeleteFileFolder/DeleteFileFolder.cs +++ b/DeleteFileFolder/DeleteFileFolder.cs @@ -108,27 +108,29 @@ namespace Eugen.ESystem Dir = false; } - ///// - ///// Delete Files in a folder - ///// - // public DeleteFileFolder() - // { - // SetDllInfo(); + ///// + ///// Delete Files in a folder + ///// + //public DeleteFileFolder() + //{ + // SetDllInfo(); - // Dir = false; - // } + // Dir = false; + //} //public static List UndeletableFiles = new List(); //Liste der unlöschbaren Dateien - //public static List UndeletableDirectories = new List(); //Liste der unlöschbaren Verzeichnisse + //public static List UndeletableDirectories = new List(); //Liste der unlöschbaren Verzeichnisse - private static long FileCounter { set; get; } //Anzahl der abgearbeiteten Dateien + private static long FileCounter { set; get; } //Anzahl der abgearbeiteten Dateien private static long DirectoryCounter { set; get; } //Anzahl der abgearbeiteten Verzeichnisse - private static long NumberOfFiles { set; get; } //Anzahl der Dateien - private static long NumberOfDirectories { set; get; } //Anzahl der Verzeichnisse - public long PercentDone { set; get; } //Prozent abgeschlossen + public static long NumberOfFiles { set; get; } //Anzahl der Dateien + public static long NumberOfDirectories { set; get; } //Anzahl der Verzeichnisse + public static long PercentDone { set; get; } //Prozent abgeschlossen private static bool Dir { set; get; } //true = Verzeichnisse und Dateien; false = Nur Dateien + public static string Status { set; get; } //Statustext + /// /// List of undeletable files /// @@ -144,7 +146,7 @@ namespace Eugen.ESystem /// /// A valid filename with path. /// If the file was successfully deleted, 'null' is returned, otherwise the filename. - public string File(string fileName) + public static string File(string fileName) { try { @@ -167,7 +169,7 @@ namespace Eugen.ESystem /// A valid filename with path. /// A valid file extension, e.g.: .txt /// If the file was successfully deleted, 'null' is returned, otherwise the filename. - public string File(string fileName, string searchPattern) + public static string File(string fileName, string searchPattern) { try { @@ -194,7 +196,7 @@ namespace Eugen.ESystem /// /// Full path of a folder. /// Returns a list of all undeletable files. - public List AllFiles(string path) + public static List AllFiles(string path) { NumberOfFiles = CountFiles(path); //Anzahl der löschbaren Dateien @@ -217,7 +219,7 @@ namespace Eugen.ESystem { //Nur Dateien werden berücksichtigt PercentDone = Convert.ToInt32(100 / Convert.ToDouble(NumberOfFiles) * Convert.ToDouble(FileCounter)); - OnEvent(PercentDone); + OnEvent(PercentDone, Status); } if (result != null) @@ -235,7 +237,7 @@ namespace Eugen.ESystem /// Full path of a folder. /// If true, then all files in all subdirectories are also deleted. /// - public List AllFiles(string path, bool subFolder) + public static List AllFiles(string path, bool subFolder) { NumberOfFiles = CountFiles(path, subFolder); //Anzahl der löschbaren Dateien @@ -254,7 +256,7 @@ namespace Eugen.ESystem /// If true, then all files in all subdirectories are also deleted. /// A valid file extension, e.g.: .txt /// Returns a list of all undeletable files. - public List AllFiles(string path, bool subFolder, string searchPattern) + public static List AllFiles(string path, bool subFolder, string searchPattern) { NumberOfFiles = CountFiles(path, subFolder); //Anzahl der löschbaren Dateien @@ -266,7 +268,7 @@ namespace Eugen.ESystem return AllFilesInFolders(path, true, searchPattern); } - private List AllFilesInFolders(string path, bool subFolder) + private static List AllFilesInFolders(string path, bool subFolder) { string result = ""; //Rückgabewert @@ -279,13 +281,13 @@ namespace Eugen.ESystem { //Dateien un Verzeichnisse werden berücksichtigt PercentDone = Convert.ToInt32(100 / Convert.ToDouble(NumberOfFiles + NumberOfDirectories) * Convert.ToDouble(FileCounter + DirectoryCounter)); - OnEvent(PercentDone); + OnEvent(PercentDone, Status); } else { //Nur Dateien werden berücksichtigt PercentDone = Convert.ToInt32(100 / Convert.ToDouble(NumberOfFiles) * Convert.ToDouble(FileCounter)); - OnEvent(PercentDone); + OnEvent(PercentDone, Status); } if (result != null) @@ -306,7 +308,7 @@ namespace Eugen.ESystem return UndeletableFiles; //Gibt die Liste der unlöschbaren Dateien zurück } - private List AllFilesInFolders(string path, bool subFolder, string searchPattern) + private static List AllFilesInFolders(string path, bool subFolder, string searchPattern) { string result = ""; //Rückgabewert @@ -333,7 +335,7 @@ namespace Eugen.ESystem } - public string SingleDirectory(string path) + public static string SingleDirectory(string path) { try { @@ -351,7 +353,7 @@ namespace Eugen.ESystem } } - public List> AllDirectories(string path) + public static List> AllDirectories(string path) { //object[] undeleteableFilesFolders = new object[2]; List> undeleteableFilesFolders = new List>(); @@ -387,14 +389,14 @@ namespace Eugen.ESystem //Berechnen wie viel Prozenz bereits gelöscht sind PercentDone = Convert.ToInt32(100 / Convert.ToDouble(NumberOfFiles + NumberOfDirectories) * Convert.ToDouble(FileCounter + DirectoryCounter)); - OnEvent(PercentDone); + OnEvent(PercentDone, Status); undeleteableFilesFolders.Add(UndeletableFiles); undeleteableFilesFolders.Add(UndeletableDirectories); return undeleteableFilesFolders; //Gibt die Liste der unlöschbaren Dateien und Verzeichnisse zurück } - public List AllSubDirectories(string path) + private static List AllSubDirectories(string path) { //Unterverzeichnisse löschen foreach (var sFolder in Directory.GetDirectories(path)) @@ -405,7 +407,7 @@ namespace Eugen.ESystem //Berechnen wie viel Prozenz bereits gelöscht sind PercentDone = Convert.ToInt32(100 / Convert.ToDouble(NumberOfFiles + NumberOfDirectories) * Convert.ToDouble(FileCounter + DirectoryCounter)); - OnEvent(PercentDone); + OnEvent(PercentDone, Status); } return UndeletableFiles; //Gibt die Liste der unlöschbaren Dateien und Verzeichnisse zurück @@ -416,7 +418,7 @@ namespace Eugen.ESystem /// /// Full path of a folder. /// The number of files. - public long CountFiles(string path) + public static long CountFiles(string path) { long numberOfFiles = 0; //Anzahl der löschbaren Dateien @@ -434,7 +436,7 @@ namespace Eugen.ESystem /// Full path of a folder. /// If true, then all files in all subdirectories are also counted. /// The number of files. - public long CountFiles(string path, bool subFolder) + public static long CountFiles(string path, bool subFolder) { if (!Directory.Exists(path)) { @@ -454,7 +456,7 @@ namespace Eugen.ESystem /// If true, then all files in all subdirectories are also counted. /// A valid file extension, e.g.: .txt /// The number of files. - private long CountFile(string path, bool subFolder, string searchPattern) + private static long CountFile(string path, bool subFolder, string searchPattern) { long numberOfFiles = 0; //Anzahl der löschbaren Dateien @@ -476,7 +478,7 @@ namespace Eugen.ESystem return numberOfFiles; } - private long CountAllFiles(string path, bool subFolder) + private static long CountAllFiles(string path, bool subFolder) { foreach (var file in Directory.GetFiles(path)) { @@ -493,7 +495,7 @@ namespace Eugen.ESystem return NumberOfFiles; } - private long CountAllFiles(string path, bool subFolder, string searchPattern) + private static long CountAllFiles(string path, bool subFolder, string searchPattern) { foreach (var file in Directory.GetFiles(path)) { @@ -518,7 +520,7 @@ namespace Eugen.ESystem /// /// Full path of a folder. /// The number of directories. - public long CountDirectories(string path) + public static long CountDirectories(string path) { if (!Directory.Exists(path)) { @@ -531,7 +533,7 @@ namespace Eugen.ESystem return NumberOfDirectories; } - private long CountAllDirectories(string path) + private static long CountAllDirectories(string path) { //Rekursive Aufruf foreach (var sFolder in Directory.GetDirectories(path)) @@ -595,17 +597,17 @@ namespace Eugen.ESystem #region Event Handler // Der Delegat muß die gleiche Signatur aufweisen wie die Eventhandler-Methode. - public delegate void EventDelegate(long result); + public delegate void EventDelegate(long result, string status); // Das Event-Objekt ist vom Typ dieses Delegaten. - public event EventDelegate MyEvent; + public static event EventDelegate MyEvent; - public void OnEvent(long result) + public static void OnEvent(long result, string status) { // Prüft ob das Event überhaupt einen Abonnenten hat. if (MyEvent != null) { - MyEvent(result); + MyEvent(result, status); } } #endregion diff --git a/DeleteFileFolder/DeleteFileFolder.csproj b/DeleteFileFolder/DeleteFileFolder.csproj index a1ce2d5..ef6eed3 100644 --- a/DeleteFileFolder/DeleteFileFolder.csproj +++ b/DeleteFileFolder/DeleteFileFolder.csproj @@ -43,7 +43,20 @@ + + True + True + AppResources.resx + + + + + + ResXFileCodeGenerator + AppResources.Designer.cs + + \ No newline at end of file diff --git a/DeleteFileFolder/bin/Debug/hedff.dll b/DeleteFileFolder/bin/Debug/hedff.dll index c86bfdb..7154130 100644 Binary files a/DeleteFileFolder/bin/Debug/hedff.dll and b/DeleteFileFolder/bin/Debug/hedff.dll differ diff --git a/DeleteFileFolder/bin/Debug/hedff.pdb b/DeleteFileFolder/bin/Debug/hedff.pdb index 7eeca67..a43454c 100644 Binary files a/DeleteFileFolder/bin/Debug/hedff.pdb and b/DeleteFileFolder/bin/Debug/hedff.pdb differ diff --git a/DeleteFileFolder/obj/Debug/DeleteFileFolder.csproj.AssemblyReference.cache b/DeleteFileFolder/obj/Debug/DeleteFileFolder.csproj.AssemblyReference.cache index 6227aa3..2b49b7c 100644 Binary files a/DeleteFileFolder/obj/Debug/DeleteFileFolder.csproj.AssemblyReference.cache and b/DeleteFileFolder/obj/Debug/DeleteFileFolder.csproj.AssemblyReference.cache differ diff --git a/DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..a670d77 Binary files /dev/null and b/DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/DeleteFileFolder/obj/Debug/TempPE/Properties.AppResources.Designer.cs.dll b/DeleteFileFolder/obj/Debug/TempPE/Properties.AppResources.Designer.cs.dll new file mode 100644 index 0000000..501f8a4 Binary files /dev/null and b/DeleteFileFolder/obj/Debug/TempPE/Properties.AppResources.Designer.cs.dll differ diff --git a/DeleteFileFolder/obj/Debug/hedff.dll b/DeleteFileFolder/obj/Debug/hedff.dll index c86bfdb..7154130 100644 Binary files a/DeleteFileFolder/obj/Debug/hedff.dll and b/DeleteFileFolder/obj/Debug/hedff.dll differ diff --git a/DeleteFileFolder/obj/Debug/hedff.pdb b/DeleteFileFolder/obj/Debug/hedff.pdb index 7eeca67..a43454c 100644 Binary files a/DeleteFileFolder/obj/Debug/hedff.pdb and b/DeleteFileFolder/obj/Debug/hedff.pdb differ diff --git a/Test_DeleteFileFolder/Form1.cs b/Test_DeleteFileFolder/Form1.cs index 429373b..7027e27 100644 --- a/Test_DeleteFileFolder/Form1.cs +++ b/Test_DeleteFileFolder/Form1.cs @@ -129,15 +129,14 @@ namespace Test_DeleteFileFolder string message = ""; //In diesem Bereich wird das Löschen ausgeführt --------------------- - DeleteFileFolder Del = new DeleteFileFolder(); // Hier wird das Event abonniert. // Das kann jede Klasse auf die gleiche Weise machen. - Del.MyEvent += new DeleteFileFolder.EventDelegate(EventHandler); + DeleteFileFolder.MyEvent += new DeleteFileFolder.EventDelegate(EventHandler); if (checkBoxCountOnly.Checked) { - labelDeletableFiles.Text = "Number of deletable Files: " + Del.CountFiles(textBoxFileName.Text, checkBoxSubdirectories.Checked); - labelDeletableDirectories.Text = "Number of deletable Directories: \t" + Del.CountDirectories(textBoxFileName.Text); + labelDeletableFiles.Text = "Number of deletable Files: " + DeleteFileFolder.CountFiles(textBoxFileName.Text, checkBoxSubdirectories.Checked); + labelDeletableDirectories.Text = "Number of deletable Directories: \t" + DeleteFileFolder.CountDirectories(textBoxFileName.Text); } else { @@ -146,24 +145,24 @@ namespace Test_DeleteFileFolder //Dateien löschen if (radioButtonSingleFile.Checked) { - undeletableFile = Del.File(textBoxFileName.Text); //Eine einzelen Datei löschen + undeletableFile = DeleteFileFolder.File(textBoxFileName.Text); //Eine einzelen Datei löschen progressBar.Value = 100; } else { if (!checkBoxSubdirectories.Checked) { - undeletableFiles = Del.AllFiles(textBoxFileName.Text); //Alle Dateien eines Verzeichnisses löschen + undeletableFiles = DeleteFileFolder.AllFiles(textBoxFileName.Text); //Alle Dateien eines Verzeichnisses löschen } else { - undeletableFiles = Del.AllFiles(textBoxFileName.Text, true); //Alle Dateien eines Verzeichnisses und aller Unterverzeichnisse löschen + undeletableFiles = DeleteFileFolder.AllFiles(textBoxFileName.Text, true); //Alle Dateien eines Verzeichnisses und aller Unterverzeichnisse löschen } } } else { - undeleteableFilesFolders = Del.AllDirectories(textBoxFileName.Text); //Alle Verzeichnisse löschen + undeleteableFilesFolders = DeleteFileFolder.AllDirectories(textBoxFileName.Text); //Alle Verzeichnisse löschen } } @@ -234,7 +233,7 @@ namespace Test_DeleteFileFolder } #region Event Handler - void EventHandler(long value) + void EventHandler(long value, string Status) { //Die ProgressBar updaten progressBar.Value = Convert.ToInt32(value); diff --git a/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 4111691..ca1b6f9 100644 Binary files a/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 847fcbc..0168f44 100644 Binary files a/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Test_DeleteFileFolder/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Test_DeleteFileFolder/obj/Debug/Test_DeleteFileFolder.csproj.AssemblyReference.cache b/Test_DeleteFileFolder/obj/Debug/Test_DeleteFileFolder.csproj.AssemblyReference.cache index a9dafc8..bbe8cc1 100644 Binary files a/Test_DeleteFileFolder/obj/Debug/Test_DeleteFileFolder.csproj.AssemblyReference.cache and b/Test_DeleteFileFolder/obj/Debug/Test_DeleteFileFolder.csproj.AssemblyReference.cache differ