Kleine Korrektur
This commit is contained in:
parent
78ce0652b3
commit
8e5fd3ae36
Binary file not shown.
0
.vs/DeleteFileFolder.git/FileContentIndex/read.lock
Normal file
0
.vs/DeleteFileFolder.git/FileContentIndex/read.lock
Normal file
Binary file not shown.
@ -111,12 +111,12 @@ namespace Eugen.ESystem
|
||||
///// <summary>
|
||||
///// Delete Files in a folder
|
||||
///// </summary>
|
||||
// public DeleteFileFolder()
|
||||
// {
|
||||
//public DeleteFileFolder()
|
||||
//{
|
||||
// SetDllInfo();
|
||||
|
||||
// Dir = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static List<string> UndeletableFiles = new List<string>(); //Liste der unlöschbaren Dateien
|
||||
//public static List<string> UndeletableDirectories = new List<string>(); //Liste der unlöschbaren Verzeichnisse
|
||||
@ -124,11 +124,13 @@ namespace Eugen.ESystem
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// List of undeletable files
|
||||
/// </summary>
|
||||
@ -144,7 +146,7 @@ namespace Eugen.ESystem
|
||||
/// </summary>
|
||||
/// <param name="fileName">A valid filename with path.</param>
|
||||
/// <returns>If the file was successfully deleted, 'null' is returned, otherwise the filename.</returns>
|
||||
public string File(string fileName)
|
||||
public static string File(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -167,7 +169,7 @@ namespace Eugen.ESystem
|
||||
/// <param name="fileName">A valid filename with path.</param>
|
||||
/// <param name="searchPattern">A valid file extension, e.g.: .txt</param>
|
||||
/// <returns>If the file was successfully deleted, 'null' is returned, otherwise the filename.</returns>
|
||||
public string File(string fileName, string searchPattern)
|
||||
public static string File(string fileName, string searchPattern)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -194,7 +196,7 @@ namespace Eugen.ESystem
|
||||
/// </summary>
|
||||
/// <param name="path">Full path of a folder.</param>
|
||||
/// <returns>Returns a list of all undeletable files.</returns>
|
||||
public List<string> AllFiles(string path)
|
||||
public static List<string> 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
|
||||
/// <param name="path">Full path of a folder.</param>
|
||||
/// <param name="subFolder">If true, then all files in all subdirectories are also deleted.</param>
|
||||
/// <returns></returns>
|
||||
public List<string> AllFiles(string path, bool subFolder)
|
||||
public static List<string> AllFiles(string path, bool subFolder)
|
||||
{
|
||||
NumberOfFiles = CountFiles(path, subFolder); //Anzahl der löschbaren Dateien
|
||||
|
||||
@ -254,7 +256,7 @@ namespace Eugen.ESystem
|
||||
/// <param name="subFolder">If true, then all files in all subdirectories are also deleted.</param>
|
||||
/// <param name="searchPattern">A valid file extension, e.g.: .txt</param>
|
||||
/// <returns>Returns a list of all undeletable files.</returns>
|
||||
public List<string> AllFiles(string path, bool subFolder, string searchPattern)
|
||||
public static List<string> 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<string> AllFilesInFolders(string path, bool subFolder)
|
||||
private static List<string> 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<string> AllFilesInFolders(string path, bool subFolder, string searchPattern)
|
||||
private static List<string> 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<List<string>> AllDirectories(string path)
|
||||
public static List<List<string>> AllDirectories(string path)
|
||||
{
|
||||
//object[] undeleteableFilesFolders = new object[2];
|
||||
List<List<string>> undeleteableFilesFolders = new List<List<string>>();
|
||||
@ -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<string> AllSubDirectories(string path)
|
||||
private static List<string> 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
|
||||
/// </summary>
|
||||
/// <param name="path">Full path of a folder.</param>
|
||||
/// <returns>The number of files.</returns>
|
||||
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
|
||||
/// <param name="path">Full path of a folder.</param>
|
||||
/// <param name="subFolder">If true, then all files in all subdirectories are also counted.</param>
|
||||
/// <returns>The number of files.</returns>
|
||||
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
|
||||
/// <param name="subFolder">If true, then all files in all subdirectories are also counted.</param>
|
||||
/// <param name="searchPattern">A valid file extension, e.g.: .txt</param>
|
||||
/// <returns>The number of files.</returns>
|
||||
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
|
||||
/// </summary>
|
||||
/// <param name="path">Full path of a folder.</param>
|
||||
/// <returns>The number of directories.</returns>
|
||||
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
|
||||
|
||||
@ -43,7 +43,20 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DeleteFileFolder.cs" />
|
||||
<Compile Include="Properties\AppResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>AppResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\AppResources.de.resx" />
|
||||
<EmbeddedResource Include="Properties\AppResources.en.resx" />
|
||||
<EmbeddedResource Include="Properties\AppResources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user