Änderung

- Doppelte File Extension wird vermieden
This commit is contained in:
Eugen Höglinger 2021-08-26 15:28:36 +02:00
parent 866676ef53
commit 07a3c208d5
14 changed files with 17 additions and 3 deletions

Binary file not shown.

View File

@ -340,13 +340,27 @@ namespace Eugen.ESystem.IO
else else
{ {
if (this.path[this.path.Length - 1] != System.IO.Path.DirectorySeparatorChar) if (this.path[this.path.Length - 1] != System.IO.Path.DirectorySeparatorChar)
{
if (String.IsNullOrEmpty(System.IO.Path.GetExtension(this.filename)))
{ {
fileName = String.Concat(path, System.IO.Path.DirectorySeparatorChar, this.filename, ".log"); fileName = String.Concat(path, System.IO.Path.DirectorySeparatorChar, this.filename, ".log");
} }
else else
{
fileName = String.Concat(path, System.IO.Path.DirectorySeparatorChar, this.filename);
}
}
else
{
if (String.IsNullOrEmpty(System.IO.Path.GetExtension(this.filename)))
{ {
fileName = String.Concat(this.path, this.filename, ".log"); fileName = String.Concat(this.path, this.filename, ".log");
} }
else
{
fileName = String.Concat(this.path, this.filename);
}
}
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -135,7 +135,7 @@ namespace Test_LogWriter
logWriter1.WriteMessage("Das ist ein Test"); logWriter1.WriteMessage("Das ist ein Test");
//Variante 2 - Logdateiname wird angegeben, z.B. 'my_logfile.log' //Variante 2 - Logdateiname wird angegeben, z.B. 'my_logfile.log'
var logWriter2 = new LogWriter(@"C:\TMP\", "my_logfile2"); var logWriter2 = new LogWriter(@"C:\TMP\", "my_logfile2.log");
logWriter2.WriteMessage("Das ist Test 2"); logWriter2.WriteMessage("Das ist Test 2");
//Variante 3 - Logdateiname wird angegeben und Header wird geschrieben //Variante 3 - Logdateiname wird angegeben und Header wird geschrieben