Projektdateien hinzufügen.
This commit is contained in:
parent
39877e68f6
commit
a08a68fda3
22
Test_Delete.sln
Normal file
22
Test_Delete.sln
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.26430.14
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Delete", "Test_Delete\Test_Delete.csproj", "{EE2CCB92-EABE-412D-97BB-6BF7A1077413}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{EE2CCB92-EABE-412D-97BB-6BF7A1077413}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EE2CCB92-EABE-412D-97BB-6BF7A1077413}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EE2CCB92-EABE-412D-97BB-6BF7A1077413}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EE2CCB92-EABE-412D-97BB-6BF7A1077413}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Test_Delete/App.config
Normal file
6
Test_Delete/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
571
Test_Delete/Count.cs
Normal file
571
Test_Delete/Count.cs
Normal file
@ -0,0 +1,571 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Eugen.IO
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Count files and/or directories
|
||||||
|
/// </summary>
|
||||||
|
class Count
|
||||||
|
{
|
||||||
|
#region Variablen
|
||||||
|
protected static long NumberOfFiles { set; get; } //Anzahl der Dateien
|
||||||
|
protected static long NumberOfDirectories { set; get; } //Anzahl der Verzeichnisse
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Konstruktor
|
||||||
|
/// <summary>
|
||||||
|
/// Count files or Directories in a directory.
|
||||||
|
/// </summary>
|
||||||
|
public Count()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region File
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all files in a directory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <returns>Number of found files.</returns>
|
||||||
|
public long File(string directoryName)
|
||||||
|
{
|
||||||
|
//Zählt alle Dateien in einem Verzeichnis
|
||||||
|
long numberOfFiles = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string fileName in System.IO.Directory.GetFiles(directoryName))
|
||||||
|
{
|
||||||
|
numberOfFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all files in a directory that correspond to a particular pattern sequence.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <returns>Number of found files.</returns>
|
||||||
|
public long File(string directoryName, string searchPattern)
|
||||||
|
{
|
||||||
|
//Zählt alle Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen
|
||||||
|
//Gültige Suchpattern: "", ".txt", "*.txt", "*xyz*", "Xyz*", "*xyz", "wx*yz"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
long numberOfFiles = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string fileName in System.IO.Directory.GetFiles(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternFile(fileName, searchPattern))
|
||||||
|
{
|
||||||
|
numberOfFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all files in a directory that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <param name="daysOld">Days the file must be old. 0=All files are counted.</param>
|
||||||
|
/// <returns>Number of found files.</returns>
|
||||||
|
public long File(string directoryName, string searchPattern, int daysOld)
|
||||||
|
{
|
||||||
|
//Zählt alle Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", ".txt", "*.txt", "*xyz*", "Xyz*", "*xyz", "wx*yz"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
long numberOfFiles = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string fileName in System.IO.Directory.GetFiles(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternFile(fileName, searchPattern) && DaysOld(fileName, daysOld))
|
||||||
|
{
|
||||||
|
numberOfFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all files in a directory and all subdirectories that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <param name="daysOld">Days the file must be old. 0=All files are counted.</param>
|
||||||
|
/// <param name="recursive">True=Search in all sudirectories recursive. False=Search only in root directory.</param>
|
||||||
|
/// <returns>Number of found files.</returns>
|
||||||
|
public long File(string directoryName, string searchPattern, int daysOld, bool recursive)
|
||||||
|
{
|
||||||
|
//Löscht alle Dateien im angegebenen Verzeichnis und allen Unterverzeichnissen die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", ".txt", "*.txt", "*xyz*", "Xyz*", "*xyz", "wx*yz"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
long numberOfFiles = 0;
|
||||||
|
long tempNumberOfFiles = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string fileName in System.IO.Directory.GetFiles(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternFile(fileName, searchPattern) && DaysOld(fileName, daysOld))
|
||||||
|
{
|
||||||
|
numberOfFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recursive)
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
tempNumberOfFiles = File(dirName, searchPattern, daysOld, recursive);
|
||||||
|
|
||||||
|
numberOfFiles = numberOfFiles + tempNumberOfFiles;
|
||||||
|
tempNumberOfFiles = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfFiles;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Directory
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all directories in a directory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <returns>Number of found directories.</returns>
|
||||||
|
public long Directory(string directoryName)
|
||||||
|
{
|
||||||
|
//Zählt das angegebene Verzeichnis
|
||||||
|
long numberOfDirectories = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
numberOfDirectories++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfDirectories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all directories in a directory that correspond to a particular pattern sequence.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All directories.</param>
|
||||||
|
/// <returns>Number of found directories.</returns>
|
||||||
|
public long Directory(string directoryName, string searchPattern)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
long numberOfDirectories = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternDirectory(dirName, searchPattern))
|
||||||
|
{
|
||||||
|
numberOfDirectories++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfDirectories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all directories in a directory that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All directories.</param>
|
||||||
|
/// <param name="daysOld">Days the directory must be old. 0=All files are counted.</param>
|
||||||
|
/// <returns>Number of found directories.</returns>
|
||||||
|
public long Directory(string directoryName, string searchPattern, int daysOld)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
long numberOfDirectories = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternDirectory(dirName, searchPattern) && DaysOld(dirName, daysOld))
|
||||||
|
{
|
||||||
|
numberOfDirectories++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfDirectories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all directories and all subdirectories in a directory that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All directories.</param>
|
||||||
|
/// <param name="daysOld">Days the directory must be old. 0=All files are counted.</param>
|
||||||
|
/// <param name="recursive">True=Search in all sudirectories recursive. False=Search only in root directory.</param>
|
||||||
|
/// <returns>Number of found directories.</returns>
|
||||||
|
public long Directory(string directoryName, string searchPattern, int daysOld, bool recursive)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis und allen Unterverzeichnissen
|
||||||
|
//die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
long numberOfDirectories = 0;
|
||||||
|
long tempNumberOfDirectories = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternDirectory(dirName, searchPattern) && DaysOld(dirName, daysOld))
|
||||||
|
{
|
||||||
|
numberOfDirectories++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recursive)
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
tempNumberOfDirectories = Directory(dirName, searchPattern, daysOld, recursive);
|
||||||
|
|
||||||
|
numberOfDirectories = numberOfDirectories + tempNumberOfDirectories;
|
||||||
|
tempNumberOfDirectories = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfDirectories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts all directories and all subdirectories in a directory and the directory itself that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All directories.</param>
|
||||||
|
/// <param name="daysOld">Days the directory must be old. 0=All files are counted.</param>
|
||||||
|
/// <param name="recursive">True=Search in all sudirectories recursive. False=Search only in root directory.</param>
|
||||||
|
/// <param name="countItself">True=Add the directory itself to the counter, false=The directory itself is not added to the counter.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public long Directory(string directoryName, string searchPattern, int daysOld, bool recursive, bool countItself)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis und allen Unterverzeichnissen
|
||||||
|
//die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
long numberOfDirectories = 0;
|
||||||
|
|
||||||
|
numberOfDirectories = Directory(directoryName, searchPattern, daysOld, recursive);
|
||||||
|
|
||||||
|
if (countItself)
|
||||||
|
{
|
||||||
|
numberOfDirectories++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfDirectories;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Subroutines
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether the search pattern is included in the file name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">A valid file name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <returns>The search pattern is included in the file name=true, otherwise=false.</returns>
|
||||||
|
private bool SearchPatternFile(string fileName, string searchPattern)
|
||||||
|
{
|
||||||
|
string tempFileName = "";
|
||||||
|
string tempExtension = "";
|
||||||
|
string tempPattern = "";
|
||||||
|
string tempPattern1 = "";
|
||||||
|
bool match = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (searchPattern == "")
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith(".") | searchPattern.StartsWith("*."))
|
||||||
|
{
|
||||||
|
//Wenn mit '*', dann '*' entfernen
|
||||||
|
if (searchPattern.StartsWith("*"))
|
||||||
|
{
|
||||||
|
searchPattern = searchPattern.Replace("*", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Nach Datei Erweiterung suchen
|
||||||
|
if (Path.GetExtension(fileName).ToLower() == searchPattern.ToLower())
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*") & searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Teilstück suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempFileName.Contains(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang Suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempFileName.StartsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*") & searchPattern.Contains("."))
|
||||||
|
{
|
||||||
|
//Nach Teilstück suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
tempPattern = tempPattern.Remove(tempPattern.IndexOf("."));
|
||||||
|
tempExtension = Path.GetExtension(fileName).ToLower();
|
||||||
|
string test = searchPattern.Remove(0, searchPattern.IndexOf("."));
|
||||||
|
|
||||||
|
if (tempFileName.EndsWith(tempPattern) & searchPattern.Remove(0, searchPattern.IndexOf(".")) == tempExtension)
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Ende Suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempFileName.EndsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.Contains("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang und Ende Suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Remove(searchPattern.IndexOf("*"));
|
||||||
|
tempPattern1 = searchPattern.Remove(0, searchPattern.IndexOf("*") + 1);
|
||||||
|
|
||||||
|
if (tempFileName.StartsWith(tempPattern) & tempFileName.EndsWith(tempPattern1))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether the search pattern is included in the directory name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All directories.</param>
|
||||||
|
/// <returns>The search pattern is included in the directory name=true, otherwise=false.</returns>
|
||||||
|
private bool SearchPatternDirectory(string directoryName, string searchPattern)
|
||||||
|
{
|
||||||
|
string tempDirectoryName = "";
|
||||||
|
string tempPattern = "";
|
||||||
|
string tempPattern1 = "";
|
||||||
|
bool match = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (searchPattern == "")
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*") & searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Teilstück suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempDirectoryName.Contains(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang Suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempDirectoryName.StartsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Ende Suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempDirectoryName.EndsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.Contains("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang und Ende Suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Remove(searchPattern.IndexOf("*"));
|
||||||
|
tempPattern1 = searchPattern.Remove(0, searchPattern.IndexOf("*") + 1);
|
||||||
|
|
||||||
|
if (tempDirectoryName.StartsWith(tempPattern) & tempDirectoryName.EndsWith(tempPattern1))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks how old the file is.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">A valid file or directory name.</param>
|
||||||
|
/// <param name="daysOld">Days how old the element must be. 0=All.</param>
|
||||||
|
/// <returns>True=Is older as 'daysOld', otherwies=false.</returns>
|
||||||
|
private bool DaysOld(string fileName, int daysOld)
|
||||||
|
{
|
||||||
|
int calcDays = 0;
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
if (daysOld <= 0)
|
||||||
|
{
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Das Alter (letzter Zugriff) der Datei errechnen
|
||||||
|
DateTime dt = System.IO.File.GetLastAccessTime(fileName);
|
||||||
|
TimeSpan sp = DateTime.Now - dt;
|
||||||
|
calcDays = sp.Days;
|
||||||
|
|
||||||
|
if (calcDays > daysOld)
|
||||||
|
{
|
||||||
|
//Wenn die Datei älter als 'daysOld'-Tage ist
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Event Handler
|
||||||
|
// Der Delegat muß die gleiche Signatur aufweisen wie die Eventhandler-Methode.
|
||||||
|
public delegate void EventDelegate(int result, string status);
|
||||||
|
|
||||||
|
// Das Event-Objekt ist vom Typ dieses Delegaten.
|
||||||
|
public event EventDelegate DelStatus;
|
||||||
|
|
||||||
|
public void OnEvent(int result, string status)
|
||||||
|
{
|
||||||
|
// Prüft ob das Event überhaupt einen Abonnenten hat.
|
||||||
|
if (DelStatus != null)
|
||||||
|
{
|
||||||
|
DelStatus(result, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
754
Test_Delete/Delete.cs
Normal file
754
Test_Delete/Delete.cs
Normal file
@ -0,0 +1,754 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Eugen.IO
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes files and/or directories
|
||||||
|
/// </summary>
|
||||||
|
class Delete
|
||||||
|
{
|
||||||
|
#region Variablen
|
||||||
|
List<string> undeletableFiles = new List<string>(); //Liste der unlöschbaren Dateien
|
||||||
|
List<string> undeletableDirectories = new List<string>(); //Liste der unlöschbaren Verzeichnisse
|
||||||
|
|
||||||
|
public static long FileCounter { set; get; } //Anzahl der abgearbeiteten Dateien
|
||||||
|
public static long DirectoryCounter { set; get; } //Anzahl der abgearbeiteten Verzeichnisse
|
||||||
|
|
||||||
|
public static long NumberOfFiles { set; get; } //Anzahl der Dateien
|
||||||
|
public static long NumberOfDirectories { set; get; } //Anzahl der Verzeichnisse
|
||||||
|
|
||||||
|
public static List<string> UndeletableFiles { set; get; } //Liste aller unlöschbaren Dateien
|
||||||
|
public static List<string> UndeletableDirectories { set; get; } //Liste aller unlöschbaren Verzeichnisse
|
||||||
|
|
||||||
|
public static int PercentDone { set; get; } //Prozent abgeschlossen
|
||||||
|
public static string Status { set; get; } //Zeigt an welche Datei gerade gelöscht wird
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Konstruktor
|
||||||
|
/// <summary>
|
||||||
|
/// Delete files or directories in a directory.
|
||||||
|
/// </summary>
|
||||||
|
public Delete()
|
||||||
|
{
|
||||||
|
UndeletableFiles = undeletableFiles;
|
||||||
|
UndeletableDirectories = undeletableDirectories;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region File
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes a singel file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">A valid filename with path.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string File(string fileName)
|
||||||
|
{
|
||||||
|
//Löscht eine Datei
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Wert für ProgressBar berechnen
|
||||||
|
FileCounter++; //Zähler hochzählen
|
||||||
|
if ((NumberOfFiles + NumberOfDirectories) == 0)
|
||||||
|
{
|
||||||
|
PercentDone = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PercentDone = Convert.ToInt32(100 / Convert.ToDouble(NumberOfFiles + NumberOfDirectories) * Convert.ToDouble(FileCounter + DirectoryCounter));
|
||||||
|
}
|
||||||
|
if (PercentDone > 100)
|
||||||
|
{
|
||||||
|
PercentDone = 100; //Auf max 100% begrenzen
|
||||||
|
}
|
||||||
|
Status = String.Concat("Delete ", fileName);
|
||||||
|
OnEvent(PercentDone, Status);
|
||||||
|
|
||||||
|
System.IO.File.SetAttributes(fileName, FileAttributes.Normal); //Attribute zurücksetzen
|
||||||
|
System.IO.File.Delete(fileName); //Datei löschen
|
||||||
|
|
||||||
|
return null; //Wenn löschen möglich war
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
UndeletableFiles.Add(fileName); //Dateiname in die Liste der unlöschbaren Dateien aufnehmen
|
||||||
|
return fileName; //Wenn löschen nicht möglich war
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes a file in a directory that correspond to a particular pattern sequence.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <returns>If the file was successfully deleted, 'null' is returned, otherwise the filename.</returns>
|
||||||
|
public List<string> File(string directoryName, string searchPattern)
|
||||||
|
{
|
||||||
|
//Löscht alle Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen
|
||||||
|
//Gültige Suchpattern: "", ".txt", "*.txt", "*xyz*", "Xyz*", "*xyz", "wx*yz"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
List<string> undeletableFiles = new List<string>(); //Liste der unlöschbaren Dateien
|
||||||
|
string tempUndelFile = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string fileName in System.IO.Directory.GetFiles(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternFile(fileName, searchPattern))
|
||||||
|
{
|
||||||
|
//Wenn Datei dem Suchpattern entspricht, dann löschen
|
||||||
|
tempUndelFile = File(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wenn ein Dateiname zurückgeliefert wird, dann in die Liste aufnehmen
|
||||||
|
if (tempUndelFile != null)
|
||||||
|
{
|
||||||
|
undeletableFiles.Add(tempUndelFile);
|
||||||
|
tempUndelFile = null; //Variable wieder zurücksetzen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return undeletableFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes a file in a directory that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <param name="daysOld">Days the file must be old. 0=All files are counted.</param>
|
||||||
|
/// <returns>If the file was successfully deleted, 'null' is returned, otherwise the filename.</returns>
|
||||||
|
public List<string> File(string directoryName, string searchPattern, int daysOld)
|
||||||
|
{
|
||||||
|
//Löscht alle Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", ".txt", "*.txt", "*xyz*", "Xyz*", "*xyz", "wx*yz"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
List<string> undeletableFiles = new List<string>(); //Liste der unlöschbaren Dateien
|
||||||
|
string tempUndelFile = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string fileName in System.IO.Directory.GetFiles(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternFile(fileName, searchPattern) && DaysOld(fileName, daysOld))
|
||||||
|
{
|
||||||
|
//Wenn Datei dem Suchpattern entspricht, dann löschen
|
||||||
|
tempUndelFile = File(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wenn ein Dateiname zurückgeliefert wird, dann in die Liste aufnehmen
|
||||||
|
if (tempUndelFile != null)
|
||||||
|
{
|
||||||
|
undeletableFiles.Add(tempUndelFile);
|
||||||
|
tempUndelFile = null; //Variable wieder zurücksetzen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return undeletableFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes a file in a directory and all subdirectories that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <param name="daysOld">Days the file must be old. 0=All files are counted.</param>
|
||||||
|
/// <param name="recursive">True=Search in all sudirectories recursive. False=Search only in root directory.</param>
|
||||||
|
/// <returns>If the file was successfully deleted, 'null' is returned, otherwise the filename.</returns>
|
||||||
|
public List<string> File(string directoryName, string searchPattern, int daysOld, bool recursive)
|
||||||
|
{
|
||||||
|
//Löscht alle Dateien im angegebenen Verzeichnis und allen Unterverzeichnissen die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", ".txt", "*.txt", "*xyz*", "Xyz*", "*xyz", "wx*yz"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
List<string> undeletableFiles = new List<string>(); //Liste der unlöschbaren Dateien
|
||||||
|
List<string> tempUndeletableFiles = new List<string>();
|
||||||
|
string tempUndelFile = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string fileName in System.IO.Directory.GetFiles(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternFile(fileName, searchPattern) && DaysOld(fileName, daysOld))
|
||||||
|
{
|
||||||
|
//Wenn Datei dem Suchpattern entspricht, dann löschen
|
||||||
|
tempUndelFile = File(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wenn ein Dateiname zurückgeliefert wird, dann in die Liste aufnehmen
|
||||||
|
if (tempUndelFile != null)
|
||||||
|
{
|
||||||
|
undeletableFiles.Add(tempUndelFile);
|
||||||
|
tempUndelFile = null; //Variable wieder zurücksetzen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recursive)
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
tempUndeletableFiles = File(dirName, searchPattern, daysOld, recursive);
|
||||||
|
|
||||||
|
if (tempUndeletableFiles.Count != 0)
|
||||||
|
{
|
||||||
|
undeletableFiles.AddRange(tempUndeletableFiles); //Unlöschbare Dateien zur Liste hinzufügen
|
||||||
|
tempUndeletableFiles.Clear(); //Liste wieder leeren
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return undeletableFiles;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Directory
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the spicified directory. It is not checked whether subdirectories are included.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <returns>If the directory was successfully deleted, 'null' is returned, otherwise the directoryname.</returns>
|
||||||
|
public string Directory(string directoryName)
|
||||||
|
{
|
||||||
|
//Löscht das angegebene Verzeichnis
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Wert für ProgressBar berechnen
|
||||||
|
DirectoryCounter++; //Zähler hochzählen
|
||||||
|
if ((NumberOfFiles + NumberOfDirectories) == 0)
|
||||||
|
{
|
||||||
|
PercentDone = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PercentDone = Convert.ToInt32(100 / Convert.ToDouble(NumberOfFiles + NumberOfDirectories) * Convert.ToDouble(FileCounter + DirectoryCounter));
|
||||||
|
}
|
||||||
|
if (PercentDone > 100)
|
||||||
|
{
|
||||||
|
PercentDone = 100; //Auf max 100% begrenzen
|
||||||
|
}
|
||||||
|
Status = String.Concat("Delete ", directoryName);
|
||||||
|
OnEvent(PercentDone, Status);
|
||||||
|
|
||||||
|
if (System.IO.Directory.Exists(directoryName))
|
||||||
|
{
|
||||||
|
//Damit das Verzeichnis gelöscht werden kann, erst alle Dateien löschen
|
||||||
|
File(directoryName, "");
|
||||||
|
|
||||||
|
//Schreibschutz aufheben
|
||||||
|
DirectoryInfo dirInfo = new DirectoryInfo(directoryName);
|
||||||
|
dirInfo.Attributes = FileAttributes.Normal;
|
||||||
|
|
||||||
|
System.IO.Directory.Delete(directoryName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
UndeletableDirectories.Add(directoryName); //Verzeichnis in die Liste der unlöschbaren Verzeichnisse aufnehmen
|
||||||
|
return directoryName; //Wenn löschen nicht möglich war
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all directories in a directory that correspond to a particular pattern sequence.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "xyz*", "*xyz", "wx*yz", "*xyz*". ""=All files.</param>
|
||||||
|
/// <returns>If the directory was successfully deleted, 'null' is returned, otherwise the directoryname.</returns>
|
||||||
|
public List<string> Directory(string directoryName, string searchPattern)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
List<string> undeletableDirectories = new List<string>(); //Liste der unlöschbaren Verzeichnisse
|
||||||
|
string tempUndelDirectory = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternDirectory(dirName, searchPattern))
|
||||||
|
{
|
||||||
|
//Wenn Verzeichnis dem Suchpattern entspricht, dann löschen
|
||||||
|
tempUndelDirectory = Directory(dirName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wenn ein Verzeichnsname zurückgeliefert wird, dann in die Liste aufnehmen
|
||||||
|
if (tempUndelDirectory != null)
|
||||||
|
{
|
||||||
|
undeletableDirectories.Add(tempUndelDirectory);
|
||||||
|
tempUndelDirectory = null; //Variable wieder zurücksetzen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return undeletableDirectories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all directories in a directory that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "xyz*", "*xyz", "wx*yz", "*xyz*". ""=All files.</param>
|
||||||
|
/// <param name="daysOld">Days the directory must be old. 0=All directories are deleted.</param>
|
||||||
|
/// <returns>If the directory was successfully deleted, 'null' is returned, otherwise the directoryname.</returns>
|
||||||
|
public List<string> Directory(string directoryName, string searchPattern, int daysOld)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
List<string> undeletableDirectories = new List<string>(); //Liste der unlöschbaren Verzeichnisse
|
||||||
|
string tempUndelDirectory = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternDirectory(dirName, searchPattern) && DaysOld(dirName, daysOld))
|
||||||
|
{
|
||||||
|
//Wenn Verzeichnis dem Suchpattern entspricht, dann löschen
|
||||||
|
tempUndelDirectory = Directory(dirName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wenn ein Verzeichnsname zurückgeliefert wird, dann in die Liste aufnehmen
|
||||||
|
if (tempUndelDirectory != null)
|
||||||
|
{
|
||||||
|
undeletableDirectories.Add(tempUndelDirectory);
|
||||||
|
tempUndelDirectory = null; //Variable wieder zurücksetzen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return undeletableDirectories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all directories in a directory and all subdirectories that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "xyz*", "*xyz", "wx*yz", "*xyz*". ""=All files.</param>
|
||||||
|
/// <param name="daysOld">Days the directory must be old. 0=All directories are deleted.</param>
|
||||||
|
/// <param name="recursive">True=Search in all sudirectories recursive. False=Search only in root directory.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<string> Directory(string directoryName, string searchPattern, int daysOld, bool recursive)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis und allen Unterverzeichnissen
|
||||||
|
//die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
List<string> undeletableDirectories = new List<string>(); //Liste der unlöschbaren Verzeichnisse
|
||||||
|
List<string> tempUndeletableDirectories = new List<string>();
|
||||||
|
string tempUndelDirectory = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
if (SearchPatternDirectory(dirName, searchPattern) && DaysOld(dirName, daysOld))
|
||||||
|
{
|
||||||
|
//Wenn Verzeichnis dem Suchpattern entspricht, dann löschen
|
||||||
|
tempUndelDirectory = Directory(dirName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wenn ein Verzeichnsname zurückgeliefert wird, dann in die Liste aufnehmen
|
||||||
|
if (tempUndelDirectory != null)
|
||||||
|
{
|
||||||
|
undeletableDirectories.Add(tempUndelDirectory);
|
||||||
|
tempUndelDirectory = null; //Variable wieder zurücksetzen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recursive)
|
||||||
|
{
|
||||||
|
foreach (string dirName in System.IO.Directory.GetDirectories(directoryName))
|
||||||
|
{
|
||||||
|
tempUndeletableDirectories = Directory(dirName, searchPattern, daysOld, recursive);
|
||||||
|
|
||||||
|
if (tempUndeletableDirectories.Count != 0)
|
||||||
|
{
|
||||||
|
undeletableDirectories.AddRange(tempUndeletableDirectories); //Unlöschbare Verzeichnisse zur Liste hinzufügen
|
||||||
|
tempUndeletableDirectories.Clear(); //Liste wieder leeren
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts tun, weil nicht notwendig
|
||||||
|
}
|
||||||
|
|
||||||
|
return undeletableDirectories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all directories in a directory and all subdirectories and the directory itself that correspond to a particular pattern sequence and older than 'n'-days.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "xyz*", "*xyz", "wx*yz", "*xyz*". ""=All files.</param>
|
||||||
|
/// <param name="daysOld">Days the directory must be old. 0=All directories are deleted.</param>
|
||||||
|
/// <param name="recursive">True=Search in all sudirectories recursive. False=Search only in root directory.</param>
|
||||||
|
/// <param name="deleteItself">True=Delete also the root directory itself, False=Delete not the root directory itself.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<string> Directory(string directoryName, string searchPattern, int daysOld, bool recursive, bool deleteItself)
|
||||||
|
{
|
||||||
|
//Löscht alle Verzeichnisse und Dateien im angegebenen Verzeichnis und allen Unterverzeichnissen
|
||||||
|
//die dem Suchkriterium entsprechen und älter als n-Tage sind
|
||||||
|
//Gültige Suchpattern: "", "xyz*", "*xyz", "wx*yz", "*xyz*"
|
||||||
|
//Groß-/Kleinschreibung wird ignoriert
|
||||||
|
|
||||||
|
List<string> undeletableDirectories = new List<string>(); //Liste der unlöschbaren Verzeichnisse
|
||||||
|
List<string> tempUndeletableDirectories = new List<string>();
|
||||||
|
string tempUndelDirectory = null;
|
||||||
|
|
||||||
|
tempUndeletableDirectories = Directory(directoryName, searchPattern, daysOld, recursive);
|
||||||
|
|
||||||
|
if (tempUndeletableDirectories.Count != 0)
|
||||||
|
{
|
||||||
|
undeletableDirectories.AddRange(tempUndeletableDirectories); //Unlöschbare Verzeichnisse zur Liste hinzufügen
|
||||||
|
tempUndeletableDirectories.Clear(); //Liste wieder leeren
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deleteItself)
|
||||||
|
{
|
||||||
|
if (SearchPatternDirectory(directoryName, searchPattern) && DaysOld(directoryName, daysOld))
|
||||||
|
{
|
||||||
|
//Wenn Verzeichnis dem Suchpattern entspricht, dann löschen
|
||||||
|
tempUndelDirectory = Directory(directoryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempUndelDirectory != null)
|
||||||
|
{
|
||||||
|
undeletableDirectories.Add(tempUndelDirectory); //Unlöschbares Verzeichnis zur Liste hinzufügen
|
||||||
|
tempUndelDirectory = null; //Zurücksetzen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undeletableDirectories;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Reset Counters
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the file counter to 0.
|
||||||
|
/// </summary>
|
||||||
|
public static void ResetFileCounter()
|
||||||
|
{
|
||||||
|
FileCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the directory counter to 0.
|
||||||
|
/// </summary>
|
||||||
|
public static void ResetDirectoryCounter()
|
||||||
|
{
|
||||||
|
DirectoryCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the number of files to 0.
|
||||||
|
/// </summary>
|
||||||
|
public static void ResetNumberOfFiles()
|
||||||
|
{
|
||||||
|
NumberOfFiles = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the number of directories to 0.
|
||||||
|
/// </summary>
|
||||||
|
public static void ResetNumberOfDirectories()
|
||||||
|
{
|
||||||
|
NumberOfDirectories = 0;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Clear
|
||||||
|
/// <summary>
|
||||||
|
/// Clears the undeletabele file list.
|
||||||
|
/// </summary>
|
||||||
|
public void ClearUndeletableFiles()
|
||||||
|
{
|
||||||
|
UndeletableFiles.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears the undeletabele directory list.
|
||||||
|
/// </summary>
|
||||||
|
public void ClearUndeletableDirectories()
|
||||||
|
{
|
||||||
|
UndeletableDirectories.Clear();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Subroutines
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether the search pattern is included in the file name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">A valid file name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", ".ext", "*.ext", "*xyz.ext", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All files.</param>
|
||||||
|
/// <returns>The search pattern is included in the file name=true, otherwise=false.</returns>
|
||||||
|
private bool SearchPatternFile(string fileName, string searchPattern)
|
||||||
|
{
|
||||||
|
string tempFileName = "";
|
||||||
|
string tempExtension = "";
|
||||||
|
string tempPattern = "";
|
||||||
|
string tempPattern1 = "";
|
||||||
|
bool match = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (searchPattern == "")
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith(".") | searchPattern.StartsWith("*."))
|
||||||
|
{
|
||||||
|
//Wenn mit '*', dann '*' entfernen
|
||||||
|
if (searchPattern.StartsWith("*"))
|
||||||
|
{
|
||||||
|
searchPattern = searchPattern.Replace("*", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Nach Datei Erweiterung suchen
|
||||||
|
if (Path.GetExtension(fileName).ToLower() == searchPattern.ToLower())
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*") & searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Teilstück suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempFileName.Contains(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang Suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempFileName.StartsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*") & searchPattern.Contains("."))
|
||||||
|
{
|
||||||
|
//Nach Teilstück suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
tempPattern = tempPattern.Remove(tempPattern.IndexOf("."));
|
||||||
|
tempExtension = Path.GetExtension(fileName).ToLower();
|
||||||
|
string test = searchPattern.Remove(0, searchPattern.IndexOf("."));
|
||||||
|
|
||||||
|
if (tempFileName.EndsWith(tempPattern) & searchPattern.Remove(0, searchPattern.IndexOf(".")) == tempExtension)
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Ende Suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempFileName.EndsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.Contains("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang und Ende Suchen
|
||||||
|
tempFileName = Path.GetFileNameWithoutExtension(fileName).ToLower();
|
||||||
|
tempPattern = searchPattern.Remove(searchPattern.IndexOf("*"));
|
||||||
|
tempPattern1 = searchPattern.Remove(0, searchPattern.IndexOf("*") + 1);
|
||||||
|
|
||||||
|
if (tempFileName.StartsWith(tempPattern) & tempFileName.EndsWith(tempPattern1))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether the search pattern is included in the directory name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">A valid directory name.</param>
|
||||||
|
/// <param name="searchPattern">Valid pattern sequence: "", "*xyz*"; "Xyz*", "*xyz", "wx*yz". ""=All directories.</param>
|
||||||
|
/// <returns>The search pattern is included in the directory name=true, otherwise=false.</returns>
|
||||||
|
private bool SearchPatternDirectory(string directoryName, string searchPattern)
|
||||||
|
{
|
||||||
|
string tempDirectoryName = "";
|
||||||
|
string tempPattern = "";
|
||||||
|
string tempPattern1 = "";
|
||||||
|
bool match = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (searchPattern == "")
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*") & searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Teilstück suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempDirectoryName.Contains(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.EndsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang Suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempDirectoryName.StartsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.StartsWith("*"))
|
||||||
|
{
|
||||||
|
//Nach Ende Suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Replace("*", "").ToLower();
|
||||||
|
|
||||||
|
if (tempDirectoryName.EndsWith(tempPattern))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (searchPattern.Contains("*"))
|
||||||
|
{
|
||||||
|
//Nach Anfang und Ende Suchen
|
||||||
|
tempDirectoryName = Path.GetFileNameWithoutExtension(directoryName).ToLower();
|
||||||
|
tempPattern = searchPattern.Remove(searchPattern.IndexOf("*"));
|
||||||
|
tempPattern1 = searchPattern.Remove(0, searchPattern.IndexOf("*") + 1);
|
||||||
|
|
||||||
|
if (tempDirectoryName.StartsWith(tempPattern) & tempDirectoryName.EndsWith(tempPattern1))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks how old the file is.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">A valid file name.</param>
|
||||||
|
/// <param name="daysOld">Days how old the element must be. 0=All.</param>
|
||||||
|
/// <returns>True=Is older as 'daysOld', otherwies=false.</returns>
|
||||||
|
private bool DaysOld(string fileName, int daysOld)
|
||||||
|
{
|
||||||
|
int calcDays = 0;
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
if (daysOld <= 0)
|
||||||
|
{
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Das Alter (letzter Zugriff) der Datei errechnen
|
||||||
|
DateTime dt = System.IO.File.GetLastAccessTime(fileName);
|
||||||
|
TimeSpan sp = DateTime.Now - dt;
|
||||||
|
calcDays = sp.Days;
|
||||||
|
|
||||||
|
if (calcDays > daysOld)
|
||||||
|
{
|
||||||
|
//Wenn die Datei älter als 'daysOld'-Tage ist
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Event Handler
|
||||||
|
// Der Delegat muß die gleiche Signatur aufweisen wie die Eventhandler-Methode.
|
||||||
|
public delegate void EventDelegate(int result, string status);
|
||||||
|
|
||||||
|
// Das Event-Objekt ist vom Typ dieses Delegaten.
|
||||||
|
public event EventDelegate DelStatus;
|
||||||
|
|
||||||
|
public void OnEvent(int result, string status)
|
||||||
|
{
|
||||||
|
// Prüft ob das Event überhaupt einen Abonnenten hat.
|
||||||
|
if (DelStatus != null)
|
||||||
|
{
|
||||||
|
DelStatus(result, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
74
Test_Delete/Form1.Designer.cs
generated
Normal file
74
Test_Delete/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
namespace Test_Delete
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Erforderliche Designervariable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verwendete Ressourcen bereinigen.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Vom Windows Form-Designer generierter Code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Erforderliche Methode für die Designerunterstützung.
|
||||||
|
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonStart = new System.Windows.Forms.Button();
|
||||||
|
this.labelNumber = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonStart
|
||||||
|
//
|
||||||
|
this.buttonStart.Location = new System.Drawing.Point(13, 234);
|
||||||
|
this.buttonStart.Name = "buttonStart";
|
||||||
|
this.buttonStart.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonStart.TabIndex = 0;
|
||||||
|
this.buttonStart.Text = "Start";
|
||||||
|
this.buttonStart.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click);
|
||||||
|
//
|
||||||
|
// labelNumber
|
||||||
|
//
|
||||||
|
this.labelNumber.AutoSize = true;
|
||||||
|
this.labelNumber.Location = new System.Drawing.Point(13, 13);
|
||||||
|
this.labelNumber.Name = "labelNumber";
|
||||||
|
this.labelNumber.Size = new System.Drawing.Size(16, 13);
|
||||||
|
this.labelNumber.TabIndex = 1;
|
||||||
|
this.labelNumber.Text = "...";
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(292, 269);
|
||||||
|
this.Controls.Add(this.labelNumber);
|
||||||
|
this.Controls.Add(this.buttonStart);
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonStart;
|
||||||
|
private System.Windows.Forms.Label labelNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
67
Test_Delete/Form1.cs
Normal file
67
Test_Delete/Form1.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Eugen.IO;
|
||||||
|
|
||||||
|
namespace Test_Delete
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
#region Version und Copyright
|
||||||
|
// Version und Copyright
|
||||||
|
string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); // Den Programmnamen auslesen
|
||||||
|
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); // Die Programmversion auslesen
|
||||||
|
static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
|
||||||
|
string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
|
||||||
|
string icon = Application.StartupPath + "\\Info.bmp";
|
||||||
|
// Assembly Datum und Zeit
|
||||||
|
static DateTime value = AssemblyDateTime();
|
||||||
|
string date = value.ToShortDateString();
|
||||||
|
string time = value.ToLongTimeString();
|
||||||
|
// Programmversion berechnen
|
||||||
|
private static DateTime AssemblyDateTime()
|
||||||
|
{
|
||||||
|
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
|
||||||
|
// Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original)
|
||||||
|
return buildDateTime;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonStart_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//TODO: Hier geht es los
|
||||||
|
List<string> undelFile = new List<string>();
|
||||||
|
string undelDir = "";
|
||||||
|
List<string> undelDirs = new List<string>();
|
||||||
|
string fileName = "C:\\temp\\test.txt";
|
||||||
|
// string folderName = "C:\\temp";
|
||||||
|
string folderName = "C:\\temp\\Test";
|
||||||
|
|
||||||
|
Count count = new Count();
|
||||||
|
|
||||||
|
Delete.NumberOfFiles = count.File(folderName, "", 0, true);
|
||||||
|
Delete.NumberOfDirectories = count.Directory(folderName, "", 0, true, true);
|
||||||
|
labelNumber.Text = Delete.NumberOfFiles.ToString() + " Dateien\n" + Delete.NumberOfDirectories.ToString() + " Verzeichnisse";
|
||||||
|
labelNumber.Refresh();
|
||||||
|
|
||||||
|
Delete del = new Delete();
|
||||||
|
|
||||||
|
// undelFile = del.File(folderName, "", 0, true);
|
||||||
|
undelDir = del.Directory(folderName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Test_Delete/Form1.resx
Normal file
120
Test_Delete/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
22
Test_Delete/Program.cs
Normal file
22
Test_Delete/Program.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Test_Delete
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Test_Delete/Properties/AssemblyInfo.cs
Normal file
36
Test_Delete/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
|
// die einer Assembly zugeordnet sind.
|
||||||
|
[assembly: AssemblyTitle("Test_Delete")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Test_Delete")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||||
|
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||||
|
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||||
|
[assembly: Guid("ee2ccb92-eabe-412d-97bb-6bf7a1077413")]
|
||||||
|
|
||||||
|
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||||
|
//
|
||||||
|
// Hauptversion
|
||||||
|
// Nebenversion
|
||||||
|
// Buildnummer
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||||
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
|
// [assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
71
Test_Delete/Properties/Resources.Designer.cs
generated
Normal file
71
Test_Delete/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Dieser Code wurde von einem Tool generiert.
|
||||||
|
// Laufzeitversion: 4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
|
||||||
|
// der Code neu generiert wird.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Test_Delete.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||||
|
/// </summary>
|
||||||
|
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
|
||||||
|
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||||
|
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||||
|
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources
|
||||||
|
{
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ((resourceMan == null))
|
||||||
|
{
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test_Delete.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||||
|
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
117
Test_Delete/Properties/Resources.resx
Normal file
117
Test_Delete/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
30
Test_Delete/Properties/Settings.Designer.cs
generated
Normal file
30
Test_Delete/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Test_Delete.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
Test_Delete/Properties/Settings.settings
Normal file
7
Test_Delete/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
||||||
84
Test_Delete/Test_Delete.csproj
Normal file
84
Test_Delete/Test_Delete.csproj
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{EE2CCB92-EABE-412D-97BB-6BF7A1077413}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<RootNamespace>Test_Delete</RootNamespace>
|
||||||
|
<AssemblyName>Test_Delete</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Count.cs" />
|
||||||
|
<Compile Include="Delete.cs" />
|
||||||
|
<Compile Include="Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.cs">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
Loading…
Reference in New Issue
Block a user