using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = @"C:\Users\Gaming\Desktop\VysledkyCtecky.txt";
            String test = File.ReadAllText(path);
            string txtBuffer = "";
            string tagBuffer = "";

            Console.WriteLine("---------------------------------------------------------------");

            var rgxMatch = Regex.Matches(test, "\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}");
            foreach (Match mtch in rgxMatch) {
                Console.WriteLine("Id karty je: " + mtch + "\n");
                txtBuffer += txtBuffer + mtch+ ",";
                if (mtch.Value.Contains("88-00-29"))
                    tagBuffer = mtch.Value;
            }

            txtBuffer=txtBuffer.Remove(txtBuffer.Length - 1);

            if (tagBuffer != String.Empty)
            {
                Console.WriteLine("------------------------------------------------------------------------------");
                Console.WriteLine("Uzivatel vlastni pozadovany prvek." + "\n" + "ID prvku bylo zapsano do ZaznamTagu.txt pro dalsi autentizaci.");
                Console.WriteLine("------------------------------------------------------------------------------");
                tagBuffer = "88-00-29";
                
            }
            else {
                Console.WriteLine("----------------------------------------");
                Console.WriteLine("Uzivatel nema pozadovany prvek.");
                Console.WriteLine("----------------------------------------");
                tagBuffer = "Identifikator_Nenalezen";
            }

            File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\ZaznamTagu.txt", tagBuffer);


            Console.Read();
        }
    }
}


