commit f505d7b1acbd771501d44764d947c3a1fa40305c Author: Eugen Höglinger Date: Wed Nov 25 17:42:51 2020 +0100 Initialize diff --git a/.vs/ReadFileLineByLine.git/v16/.suo b/.vs/ReadFileLineByLine.git/v16/.suo new file mode 100644 index 0000000..5cb7032 Binary files /dev/null and b/.vs/ReadFileLineByLine.git/v16/.suo differ diff --git a/Daten/ReadFileLineByLine.txt b/Daten/ReadFileLineByLine.txt new file mode 100644 index 0000000..1eb968f --- /dev/null +++ b/Daten/ReadFileLineByLine.txt @@ -0,0 +1,8 @@ +Das ist ein Test. +Damit wird überprüft, ob die Funktion richtig arbeitet. +Das ist Zeile 3. +Das ist Zeile 4. +Und es gibt auch noch eine Zeile 6. +Zusätzlich soll geprüft werden, was passiert wenn Zeile 7 leer ist. + +Weiters wird überprüft, was passiert wenn die Datei mit einer Leerzeile endet. diff --git a/ReadFileLineByLine.git.sln b/ReadFileLineByLine.git.sln new file mode 100644 index 0000000..4e178b3 --- /dev/null +++ b/ReadFileLineByLine.git.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30621.155 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReadFileLineByLine", "ReadFileLineByLine\ReadFileLineByLine.csproj", "{D05213B3-BF4D-44B7-BE6A-9CD216923323}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_ReadFileLineByLine", "Test_ReadFileLineByLine\Test_ReadFileLineByLine.csproj", "{8C8252AA-BC16-4231-B846-2C32631F508F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D05213B3-BF4D-44B7-BE6A-9CD216923323}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D05213B3-BF4D-44B7-BE6A-9CD216923323}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D05213B3-BF4D-44B7-BE6A-9CD216923323}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D05213B3-BF4D-44B7-BE6A-9CD216923323}.Release|Any CPU.Build.0 = Release|Any CPU + {8C8252AA-BC16-4231-B846-2C32631F508F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C8252AA-BC16-4231-B846-2C32631F508F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C8252AA-BC16-4231-B846-2C32631F508F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C8252AA-BC16-4231-B846-2C32631F508F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4EAFBBA7-7049-4C4B-930B-3EA38DBB87DA} + EndGlobalSection +EndGlobal diff --git a/ReadFileLineByLine/Properties/AssemblyInfo.cs b/ReadFileLineByLine/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6e88ecd --- /dev/null +++ b/ReadFileLineByLine/Properties/AssemblyInfo.cs @@ -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("ReadFileLineByLine")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ReadFileLineByLine")] +[assembly: AssemblyCopyright("Copyright © 2020 by Eugen Höglinger")] +[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("d05213b3-bf4d-44b7-be6a-9cd216923323")] + +// 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, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ReadFileLineByLine/ReadFileLineByLine.cs b/ReadFileLineByLine/ReadFileLineByLine.cs new file mode 100644 index 0000000..2f1ddb1 --- /dev/null +++ b/ReadFileLineByLine/ReadFileLineByLine.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Eugen.ESystem +{ + public class ReadFileLineByLine + { + #region Version und Copyright + // Version und Copyright + static string dllName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + static string dllVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + static string copyright = GenerateCopyright(); + string icon = Application.StartupPath + "\\Info.bmp"; + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + string date = value.ToShortDateString(); + string time = value.ToLongTimeString(); + 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; + } + + private static string CurrentYear() + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + + private static string StartYear() + { + string startYear = ""; + if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © ")) + { + startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", ""); + while (startYear.StartsWith(" ")) + { + startYear = startYear.Remove(0, 1); + } + startYear = startYear.Remove(startYear.IndexOf(" ")); + return startYear; + } + else + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + } + + private static string GenerateCopyright() + { + string startYear = StartYear(); + string currentYear = CurrentYear(); + + if (startYear == currentYear) + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + else + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace(startYear, String.Concat(startYear, "-", currentYear)); + } + } + #endregion + + #region DLL-Info + /// + /// Contains the name of the program file + /// + public static string DllName { set; get; } + + /// + /// Contains the version of the program file + /// + public static string DllVersion { set; get; } + + /// + /// Contains the copyright notice + /// + public static string Copyright { set; get; } + + private static void SetDllInfo() + { + //Name, Version und Copyright setzen + DllName = dllName; + DllVersion = dllVersion; + Copyright = copyright; + } + #endregion + + /// + /// Read a text file line by line and store each line in a list. + /// + static ReadFileLineByLine() + { + SetDllInfo(); //Name, Version und Copyright setzen + } + + private void FileExist(string fileName) + { + //Wenn der Dateiname nicht existiert, dann eine Exception werfen + if (!File.Exists(fileName)) + { + throw new FileNotFoundException(fileName); + } + } + + /// + /// Reads the specified file line by line + /// + /// A valid file name with full path. + /// + public static List Read(string fileName) + { + List lines = new List(); + if (lines != null) + { + lines.Clear(); //Liste leeren + } + + try + { + foreach (string line in File.ReadAllLines(fileName, Encoding.Default)) + { + lines.Add(line); + } + } + catch + { + //Wenn nicht bis zum Ende gelesen werden kann, dann eine Exception werfen + throw new CannotReadFileToEndException(fileName); + } + + return lines; + } + } + + #region Exception + public class CannotReadFileToEndException : ApplicationException + { + public CannotReadFileToEndException() + { } + + public CannotReadFileToEndException(string message) : base(message) + { } + + public CannotReadFileToEndException(string message, Exception inner) : base(message, inner) + { } + } + #endregion +} diff --git a/ReadFileLineByLine/ReadFileLineByLine.csproj b/ReadFileLineByLine/ReadFileLineByLine.csproj new file mode 100644 index 0000000..f95e6ab --- /dev/null +++ b/ReadFileLineByLine/ReadFileLineByLine.csproj @@ -0,0 +1,49 @@ + + + + + Debug + AnyCPU + {D05213B3-BF4D-44B7-BE6A-9CD216923323} + Library + Properties + ReadFileLineByLine + ReadFileLineByLine + v4.7.2 + 512 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ReadFileLineByLine/bin/Debug/ReadFileLineByLine.dll b/ReadFileLineByLine/bin/Debug/ReadFileLineByLine.dll new file mode 100644 index 0000000..b8c2fd9 Binary files /dev/null and b/ReadFileLineByLine/bin/Debug/ReadFileLineByLine.dll differ diff --git a/ReadFileLineByLine/bin/Debug/ReadFileLineByLine.pdb b/ReadFileLineByLine/bin/Debug/ReadFileLineByLine.pdb new file mode 100644 index 0000000..a8d487a Binary files /dev/null and b/ReadFileLineByLine/bin/Debug/ReadFileLineByLine.pdb differ diff --git a/ReadFileLineByLine/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/ReadFileLineByLine/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/ReadFileLineByLine/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..6412f23 Binary files /dev/null and b/ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.csproj.CoreCompileInputs.cache b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..3b5a2a1 --- /dev/null +++ b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +8539d77d600fc0271cc40dc6f3a6ef95c804f677 diff --git a/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.csproj.FileListAbsolute.txt b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..3b74a6e --- /dev/null +++ b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\ReadFileLineByLine\bin\Debug\ReadFileLineByLine.dll +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\ReadFileLineByLine\bin\Debug\ReadFileLineByLine.pdb +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\ReadFileLineByLine\obj\Debug\ReadFileLineByLine.csproj.CoreCompileInputs.cache +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\ReadFileLineByLine\obj\Debug\ReadFileLineByLine.dll +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\ReadFileLineByLine\obj\Debug\ReadFileLineByLine.pdb diff --git a/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.dll b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.dll new file mode 100644 index 0000000..b8c2fd9 Binary files /dev/null and b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.dll differ diff --git a/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.pdb b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.pdb new file mode 100644 index 0000000..a8d487a Binary files /dev/null and b/ReadFileLineByLine/obj/Debug/ReadFileLineByLine.pdb differ diff --git a/Test_ReadFileLineByLine/App.config b/Test_ReadFileLineByLine/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Test_ReadFileLineByLine/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Test_ReadFileLineByLine/Form1.Designer.cs b/Test_ReadFileLineByLine/Form1.Designer.cs new file mode 100644 index 0000000..b30d3f0 --- /dev/null +++ b/Test_ReadFileLineByLine/Form1.Designer.cs @@ -0,0 +1,141 @@ +namespace Test_ReadFileLineByLine +{ + partial class Form1 + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.labelVorlage = new System.Windows.Forms.Label(); + this.labelRead = new System.Windows.Forms.Label(); + this.buttonReadFile = new System.Windows.Forms.Button(); + this.groupBoxProgramInfo = new System.Windows.Forms.GroupBox(); + this.labelProgramInfo = new System.Windows.Forms.Label(); + this.groupBoxDLLInfo = new System.Windows.Forms.GroupBox(); + this.labelDLLInfo = new System.Windows.Forms.Label(); + this.groupBoxProgramInfo.SuspendLayout(); + this.groupBoxDLLInfo.SuspendLayout(); + this.SuspendLayout(); + // + // labelVorlage + // + this.labelVorlage.AutoSize = true; + this.labelVorlage.Location = new System.Drawing.Point(13, 13); + this.labelVorlage.Name = "labelVorlage"; + this.labelVorlage.Size = new System.Drawing.Size(368, 143); + this.labelVorlage.TabIndex = 0; + this.labelVorlage.Text = resources.GetString("labelVorlage.Text"); + // + // labelRead + // + this.labelRead.AutoSize = true; + this.labelRead.Location = new System.Drawing.Point(388, 13); + this.labelRead.Name = "labelRead"; + this.labelRead.Size = new System.Drawing.Size(144, 13); + this.labelRead.TabIndex = 1; + this.labelRead.Text = "So wird die Datei eingelesen:"; + // + // buttonReadFile + // + this.buttonReadFile.Location = new System.Drawing.Point(12, 343); + this.buttonReadFile.Name = "buttonReadFile"; + this.buttonReadFile.Size = new System.Drawing.Size(776, 23); + this.buttonReadFile.TabIndex = 2; + this.buttonReadFile.Text = "Datei Zeilenweise einlesen"; + this.buttonReadFile.UseVisualStyleBackColor = true; + this.buttonReadFile.Click += new System.EventHandler(this.buttonReadFile_Click); + // + // groupBoxProgramInfo + // + this.groupBoxProgramInfo.Controls.Add(this.labelProgramInfo); + this.groupBoxProgramInfo.Location = new System.Drawing.Point(12, 372); + this.groupBoxProgramInfo.Name = "groupBoxProgramInfo"; + this.groupBoxProgramInfo.Size = new System.Drawing.Size(385, 66); + this.groupBoxProgramInfo.TabIndex = 3; + this.groupBoxProgramInfo.TabStop = false; + this.groupBoxProgramInfo.Text = "Programm Information"; + // + // labelProgramInfo + // + this.labelProgramInfo.AutoSize = true; + this.labelProgramInfo.Location = new System.Drawing.Point(7, 20); + this.labelProgramInfo.Name = "labelProgramInfo"; + this.labelProgramInfo.Size = new System.Drawing.Size(16, 13); + this.labelProgramInfo.TabIndex = 0; + this.labelProgramInfo.Text = "..."; + // + // groupBoxDLLInfo + // + this.groupBoxDLLInfo.Controls.Add(this.labelDLLInfo); + this.groupBoxDLLInfo.Location = new System.Drawing.Point(403, 372); + this.groupBoxDLLInfo.Name = "groupBoxDLLInfo"; + this.groupBoxDLLInfo.Size = new System.Drawing.Size(385, 66); + this.groupBoxDLLInfo.TabIndex = 4; + this.groupBoxDLLInfo.TabStop = false; + this.groupBoxDLLInfo.Text = "DLL Information"; + // + // labelDLLInfo + // + this.labelDLLInfo.AutoSize = true; + this.labelDLLInfo.Location = new System.Drawing.Point(7, 20); + this.labelDLLInfo.Name = "labelDLLInfo"; + this.labelDLLInfo.Size = new System.Drawing.Size(16, 13); + this.labelDLLInfo.TabIndex = 0; + this.labelDLLInfo.Text = "..."; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.groupBoxDLLInfo); + this.Controls.Add(this.groupBoxProgramInfo); + this.Controls.Add(this.buttonReadFile); + this.Controls.Add(this.labelRead); + this.Controls.Add(this.labelVorlage); + this.Name = "Form1"; + this.Text = "Form1"; + this.groupBoxProgramInfo.ResumeLayout(false); + this.groupBoxProgramInfo.PerformLayout(); + this.groupBoxDLLInfo.ResumeLayout(false); + this.groupBoxDLLInfo.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelVorlage; + private System.Windows.Forms.Label labelRead; + private System.Windows.Forms.Button buttonReadFile; + private System.Windows.Forms.GroupBox groupBoxProgramInfo; + private System.Windows.Forms.GroupBox groupBoxDLLInfo; + private System.Windows.Forms.Label labelProgramInfo; + private System.Windows.Forms.Label labelDLLInfo; + } +} + diff --git a/Test_ReadFileLineByLine/Form1.cs b/Test_ReadFileLineByLine/Form1.cs new file mode 100644 index 0000000..ff6160d --- /dev/null +++ b/Test_ReadFileLineByLine/Form1.cs @@ -0,0 +1,159 @@ +using Eugen.ESystem; +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; + +namespace Test_ReadFileLineByLine +{ + 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 programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + string copyright = GenerateCopyright(); + string icon = Application.StartupPath + "\\Info.bmp"; + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + string date = value.ToShortDateString(); + string time = value.ToLongTimeString(); + 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; + } + + private static string CurrentYear() + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + + private static string StartYear() + { + //string startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + //return startYear.Remove(0, startYear.LastIndexOf(" ") + 1); + string startYear = ""; + if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © ")) + { + startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", ""); + while (startYear.StartsWith(" ")) + { + startYear = startYear.Remove(0, 1); + } + startYear = startYear.Remove(startYear.IndexOf(" ")); + return startYear; + } + else + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + } + + private static string GenerateCopyright() + { + string startYear = StartYear(); + string currentYear = CurrentYear(); + + if (startYear == currentYear) + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + else + { + //return String.Concat(((AssemblyCopyrightAttribute)attributes[0]).Copyright, "-", currentYear); + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace(startYear, String.Concat(startYear, "-", currentYear)); + } + } + #endregion + + #region Programm-Info + /// + /// Contains the name of the program file + /// + public static string ProgramName { set; get; } + + /// + /// Contains the version of the program file + /// + public static string ProgramVersion { set; get; } + + /// + /// Contains the copyright notice + /// + public static string Copyright { set; get; } + + private void SetProgramInfo() + { + //Name, Version und Copyright setzen + ProgramName = programName; + ProgramVersion = programVersion; + Copyright = copyright; + } + #endregion + + public Form1() + { + SetProgramInfo(); + InitializeComponent(); + + ShowInformation(); //Programm- und DLL-Information anzeigen + } + + private void ShowInformation() + { + labelProgramInfo.Text = String.Concat(ProgramName, "\n", ProgramVersion, "\n", Copyright); //Programm-Information anzeigen + + // DLL-Information anzeigen + labelDLLInfo.Text = String.Concat(ReadFileLineByLine.DllName, "\n", ReadFileLineByLine.DllVersion, "\n", ReadFileLineByLine.Copyright); + } + + private void buttonReadFile_Click(object sender, EventArgs e) + { + //-------------------------------------------------------------- + //--- Diesen Bereich ins eigene Programm einfügen --- Anfang --- + //-------------------------------------------------------------- + string fileName = @"H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Daten\ReadFileLineByLine.txt"; + + try + { + DisplayResult(ReadFileLineByLine.Read(fileName)); + } + catch (Exception ex) + { + MessageBox.Show("Es ist ein Fehler passiert:\n\n" + ex.Message); + } + } + + private void DisplayResult(List lines) + { + labelRead.Text = "So wird die Datei eingelesen:\n\n"; + + for (int i = 0; i < lines.Count; i++) + { + labelRead.Text = String.Concat(labelRead.Text, "Zeile ", (i + 1).ToString(), ": ", lines[i], "\n"); + } + + if (lines.Count == 8) + { + labelRead.Text = String.Concat(labelRead.Text, "\n\n\nACHTUNG: Die Leerzeile am Dateiende wird ignoriert"); + } + } + + //-------------------------------------------------------------- + //--- Diesen Bereich ins eigene Programm einfügen --- Ende --- + //-------------------------------------------------------------- + } +} diff --git a/Test_ReadFileLineByLine/Form1.resx b/Test_ReadFileLineByLine/Form1.resx new file mode 100644 index 0000000..b39bea5 --- /dev/null +++ b/Test_ReadFileLineByLine/Form1.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Dieser Text steht in der Datei: + +Das ist ein Test. +Damit wird überprüft, ob die Funktion richtig arbeitet. +Das ist Zeile 3. +Das ist Zeile 4. +Und es gibt auch noch eine Zeile 6. +Zusätzlich soll geprüft werden, was passiert wenn Zeile 7 leer ist. +< Hier ist eine Leerzeile> +Weiters wird überprüft, was passiert wenn die Datei mit einer Leerzeile endet. +< Hier ist eine Leerzeile> + + \ No newline at end of file diff --git a/Test_ReadFileLineByLine/Program.cs b/Test_ReadFileLineByLine/Program.cs new file mode 100644 index 0000000..ebc09c3 --- /dev/null +++ b/Test_ReadFileLineByLine/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Test_ReadFileLineByLine +{ + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Test_ReadFileLineByLine/Properties/AssemblyInfo.cs b/Test_ReadFileLineByLine/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..07e33ba --- /dev/null +++ b/Test_ReadFileLineByLine/Properties/AssemblyInfo.cs @@ -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_ReadFileLineByLine")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Test_ReadFileLineByLine")] +[assembly: AssemblyCopyright("Copyright © 2020 by Eugen Höglinger")] +[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("8c8252aa-bc16-4231-b846-2c32631f508f")] + +// 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, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Test_ReadFileLineByLine/Properties/Resources.Designer.cs b/Test_ReadFileLineByLine/Properties/Resources.Designer.cs new file mode 100644 index 0000000..a50a7c1 --- /dev/null +++ b/Test_ReadFileLineByLine/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace Test_ReadFileLineByLine.Properties +{ + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // 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() + { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [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_ReadFileLineByLine.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Test_ReadFileLineByLine/Properties/Resources.resx b/Test_ReadFileLineByLine/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Test_ReadFileLineByLine/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Test_ReadFileLineByLine/Properties/Settings.Designer.cs b/Test_ReadFileLineByLine/Properties/Settings.Designer.cs new file mode 100644 index 0000000..b73c4e2 --- /dev/null +++ b/Test_ReadFileLineByLine/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace Test_ReadFileLineByLine.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; + } + } + } +} diff --git a/Test_ReadFileLineByLine/Properties/Settings.settings b/Test_ReadFileLineByLine/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Test_ReadFileLineByLine/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Test_ReadFileLineByLine/Test_ReadFileLineByLine.csproj b/Test_ReadFileLineByLine/Test_ReadFileLineByLine.csproj new file mode 100644 index 0000000..151e559 --- /dev/null +++ b/Test_ReadFileLineByLine/Test_ReadFileLineByLine.csproj @@ -0,0 +1,86 @@ + + + + + Debug + AnyCPU + {8C8252AA-BC16-4231-B846-2C32631F508F} + WinExe + Test_ReadFileLineByLine + Test_ReadFileLineByLine + v4.7.2 + 512 + true + false + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\ReadFileLineByLine\bin\Debug\ReadFileLineByLine.dll + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/Test_ReadFileLineByLine/bin/Debug/ReadFileLineByLine.dll b/Test_ReadFileLineByLine/bin/Debug/ReadFileLineByLine.dll new file mode 100644 index 0000000..b8c2fd9 Binary files /dev/null and b/Test_ReadFileLineByLine/bin/Debug/ReadFileLineByLine.dll differ diff --git a/Test_ReadFileLineByLine/bin/Debug/ReadFileLineByLine.pdb b/Test_ReadFileLineByLine/bin/Debug/ReadFileLineByLine.pdb new file mode 100644 index 0000000..a8d487a Binary files /dev/null and b/Test_ReadFileLineByLine/bin/Debug/ReadFileLineByLine.pdb differ diff --git a/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.exe b/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.exe new file mode 100644 index 0000000..c19b0fb Binary files /dev/null and b/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.exe differ diff --git a/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.exe.config b/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.exe.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.pdb b/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.pdb new file mode 100644 index 0000000..d8d795e Binary files /dev/null and b/Test_ReadFileLineByLine/bin/Debug/Test_ReadFileLineByLine.pdb differ diff --git a/Test_ReadFileLineByLine/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/Test_ReadFileLineByLine/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/Test_ReadFileLineByLine/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/Test_ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Test_ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..d277094 Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Test_ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Test_ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..9183a70 Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.Form1.resources b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.Form1.resources new file mode 100644 index 0000000..5551ea7 Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.Form1.resources differ diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.Properties.Resources.resources b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.Properties.Resources.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.Properties.Resources.resources differ diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.CopyComplete b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.CopyComplete new file mode 100644 index 0000000..e69de29 diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.CoreCompileInputs.cache b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..1009658 --- /dev/null +++ b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +6fc6d20ad2683337220e8875e6b5ab84c6599857 diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.FileListAbsolute.txt b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..29596df --- /dev/null +++ b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.FileListAbsolute.txt @@ -0,0 +1,13 @@ +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.csprojAssemblyReference.cache +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.Form1.resources +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.Properties.Resources.resources +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.csproj.GenerateResource.cache +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.csproj.CoreCompileInputs.cache +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\bin\Debug\Test_ReadFileLineByLine.exe.config +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\bin\Debug\Test_ReadFileLineByLine.exe +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\bin\Debug\Test_ReadFileLineByLine.pdb +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\bin\Debug\ReadFileLineByLine.dll +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\bin\Debug\ReadFileLineByLine.pdb +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.csproj.CopyComplete +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.exe +H:\Programmieren\Git-Repository\VisualStudio\2017\_DLL\ReadFileLineByLine.git\Test_ReadFileLineByLine\obj\Debug\Test_ReadFileLineByLine.pdb diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.GenerateResource.cache b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.GenerateResource.cache new file mode 100644 index 0000000..63ab784 Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csproj.GenerateResource.cache differ diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csprojAssemblyReference.cache b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csprojAssemblyReference.cache new file mode 100644 index 0000000..89c8c70 Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.csprojAssemblyReference.cache differ diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.exe b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.exe new file mode 100644 index 0000000..c19b0fb Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.exe differ diff --git a/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.pdb b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.pdb new file mode 100644 index 0000000..d8d795e Binary files /dev/null and b/Test_ReadFileLineByLine/obj/Debug/Test_ReadFileLineByLine.pdb differ