From ec09da5a8440964b4066e2368faf47bb411542a3 Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Mon, 24 Oct 2022 12:52:13 +0200 Subject: [PATCH] fixes #2 and #3 --- Mk0.Software.Bildduplikate/Form1.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Mk0.Software.Bildduplikate/Form1.cs b/Mk0.Software.Bildduplikate/Form1.cs index 648a8de..964ef41 100644 --- a/Mk0.Software.Bildduplikate/Form1.cs +++ b/Mk0.Software.Bildduplikate/Form1.cs @@ -12,7 +12,7 @@ namespace Mk0.Software.Bildduplikate public partial class Form1 : Form { static readonly string[] suffixes = { "Bytes", "KB", "MB", "GB", "TB", "PB" }; - private int line = 0, total = 0; + private int line = 0, total = 0, offset = 0; private string file; private List duplicates = new List(); @@ -42,6 +42,7 @@ namespace Mk0.Software.Bildduplikate line = 0; total = 0; file = fileName; + offset = 0; duplicates.Clear(); using (StreamReader reader = new StreamReader(fileName)) @@ -159,7 +160,8 @@ namespace Mk0.Software.Bildduplikate private void File_DeleteLine(int lineFile) { - lineFile++; + int linetodelete = lineFile + 1 - offset; + offset++; StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader(file)) { @@ -167,7 +169,7 @@ namespace Mk0.Software.Bildduplikate while (!sr.EndOfStream) { Countup++; - if (Countup != lineFile) + if (Countup != linetodelete) { using (StringWriter sw = new StringWriter(sb)) { @@ -184,7 +186,7 @@ namespace Mk0.Software.Bildduplikate { sw.Write(sb.ToString()); } - Debug.Print("lösche Zeile " + lineFile); + Debug.Print("lösche Zeile " + linetodelete); } } }