Änderung
- DeleteLogFile löscht jetzt auch automatisch benannte Logdateien - DeleteLogFile löscht jetzt auch Logdateien ohne Fileextension
This commit is contained in:
parent
8971cdd73c
commit
7861b7861e
Binary file not shown.
@ -433,11 +433,26 @@ namespace Eugen.ESystem.IO
|
||||
{
|
||||
try
|
||||
{
|
||||
if (String.IsNullOrEmpty(path) || String.IsNullOrEmpty(filename))
|
||||
if (String.IsNullOrEmpty(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(filename))
|
||||
{
|
||||
DateTime time = DateTime.Now;
|
||||
filename = String.Concat("log_", time.ToString().Remove(time.ToString().IndexOf(" ")), ".log");
|
||||
if (!File.Exists(String.Concat(Path, "\\", filename)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!filename.EndsWith(".log"))
|
||||
{
|
||||
filename = String.Concat(filename, ".log");
|
||||
}
|
||||
|
||||
if (!File.Exists(path + "\\" + filename))
|
||||
{
|
||||
return true;
|
||||
@ -445,7 +460,7 @@ namespace Eugen.ESystem.IO
|
||||
else
|
||||
{
|
||||
File.Delete(path + "\\" + filename);
|
||||
return true;
|
||||
//return true;
|
||||
}
|
||||
|
||||
if (File.Exists(path + "\\" + filename))
|
||||
|
||||
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.
Binary file not shown.
@ -132,17 +132,20 @@ namespace Test_LogWriter
|
||||
{
|
||||
//Variante 1 - Logdateiname ist automatisch 'log_dd-mm-yy.log'
|
||||
var logWriter1 = new LogWriter(@"C:\TMP\");
|
||||
logWriter1.DeleteLogFile();
|
||||
logWriter1.WriteMessage("Das ist Test 1");
|
||||
labelResult.Text = String.Concat("Die Log-Datei C:\\TMP\\log_", DateTime.Now.Date.ToString().Remove(10), ".log wurde geschrieben.");
|
||||
|
||||
//Variante 2 - Logdateiname wird angegeben, z.B. 'my_logfile2.log'
|
||||
var logWriter2 = new LogWriter(@"C:\TMP\", "my_logfile2.log");
|
||||
logWriter2.DeleteLogFile();
|
||||
logWriter2.WriteMessage("Das ist Test 2");
|
||||
labelResult.Text = String.Concat(labelResult.Text, "\nDie Log-Datei C:\\TMP\\my_logfile2.log wurde geschrieben");
|
||||
|
||||
//Variante 3 - Logdateiname wird angegeben und Header wird geschrieben
|
||||
string header = "--------------------\n Das ist der Header\n--------------------";
|
||||
var logWriter3 = new LogWriter(@"C:\TMP\", "my_logfile3");
|
||||
logWriter3.DeleteLogFile();
|
||||
logWriter3.WriteMessage(header, LogWriter.Time.NoWrite);
|
||||
logWriter3.WriteMessage("Das ist Test 3");
|
||||
labelResult.Text = String.Concat(labelResult.Text, "\nDie Log-Datei C:\\TMP\\my_logfile3.log wurde geschrieben");
|
||||
|
||||
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.
@ -1,7 +1,6 @@
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\Test_LogWriter.exe.config
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\Test_LogWriter.exe
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\Test_LogWriter.pdb
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\helogwri.dll
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\heshowtf.dll
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\helogwri.pdb
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\heshowtf.pdb
|
||||
@ -16,3 +15,4 @@ H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWrit
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.exe
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.pdb
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.csproj.SuggestedBindingRedirects.cache
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\helogwri.dll
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user