<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

// Efter "3" måneder, skal en artikel fjernes.
// For dato på artikel:
// dd_mm_yy_NAVN



    // Se fil navn - se directoryinfo
    // kontrol af dato
    // Fjern fil
    // I ADD skal der tilføjes dd_mm_yy 


namespace ChangeDatabase
{
    class AutomaticRemoveFromDatabase
    {
        
        public void FindOutdateFolder()
        {
            string DirectoryName = "Testfolder";
            string Path = Directory.GetCurrentDirectory();
            
            // removes \ChangeDatabase\bin\Debug from directory.
            Path = Path.Remove(Path.Length - 25); //DETTE SKAL OPTIMERES OG IKKE EKSPLICIT. ****
            Path = System.IO.Path.Combine(Path, DirectoryName);
            DirectoryInfo Dir = new DirectoryInfo(Path);

            foreach (FileInfo file in Dir.GetFiles())
                FindOutdatedFile(file.ToString(), file);
        }

        private void FindOutdatedFile(string File, FileInfo FileInformation)
        {
            try
            {
                int month = Int32.Parse(File.Substring(3, 2));
                int year = Int32.Parse(File.Substring(6, 4));
                // If current year is equal to article year
                if (year == DateTime.Now.Year)
                {
                    // If article is less than 3 months old
                    if (month > DateTime.Now.Month - 3)
                        Console.WriteLine(File);
                    else
                        RemoveFile(FileInformation);
                }
                else
                {
                    RemoveFile(FileInformation);
                }

                Console.ReadLine();
            }

            catch (FormatException)
            {
                // month or year was not converted to int. It will simply be ignored.<commit_msg>Ændret koden tilbage til det oprindelige<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

// Efter "3" måneder, skal en artikel fjernes.
// For dato på artikel:
// dd_mm_yy_NAVN



    // Se fil navn - se directoryinfo
    // kontrol af dato
    // Fjern fil
    // I ADD skal der tilføjes dd_mm_yy 


namespace ChangeDatabase
{
    class AutomaticRemoveFromDatabase
    {
        
        public void FindOutdateFolder()
        {
            string DirectoryName = "Testfolder";
            string Path = Directory.GetCurrentDirectory();
            
            // removes \ChangeDatabase\bin\Debug from directory.
            Path = Path.Remove(Path.Length - 25); //DETTE SKAL OPTIMERES OG IKKE EKSPLICIT. ****
            Path = System.IO.Path.Combine(Path, DirectoryName);
            DirectoryInfo Dir = new DirectoryInfo(Path);

            foreach (FileInfo file in Dir.GetFiles())
                FindOutdatedFile(file.ToString(), file);
        }

        private void FindOutdatedFile(string File, FileInfo FileInformation)
        {
            try
            {
                int month = Int32.Parse(File.Substring(3, 2));
                int year = Int32.Parse(File.Substring(6, 4));
                // If current year is equal to article year
                if (year == DateTime.Now.Year)
                {
                    // If article is less than 3 months old
                    if (month > DateTime.Now.Month - 3)
                        Console.WriteLine(File);
                    else
                        RemoveFile(FileInformation);
                }
                else
                {
                    RemoveFile(FileInformation);
                }

                Console.ReadLine();
            }

            catch (FormatException)
            {
                // month or year was not converted to int. It will simply be ignored.
                
{'fraction_non_alphanumeric': 0.08156028368794327, 'fraction_numerical': 0.006585612968591692, 'mean_word_length': 1.448233106013639, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3230534', 'n_tokens_mistral': 1071, 'n_tokens_neox': 985, 'n_words': 282}