Beispiel #1
0
        public static int CheckFiles(string dir_name)
        {
            var good_formats = "TXT,INI,DDS,TXB,AMA,AME,ZNO,ZNM,ZNV,DC,EV,RG,MD,MP,AT,DF,DI,PSH,VSH,LTS,XNM,MFS,SSS,GPB,MSG,AYK,ADX,AMB,CPK,CSB,PNG,CT,TGA".Split(',');

            var all_files        = Directory.GetFiles(dir_name, "*", SearchOption.AllDirectories);
            var suspicious_files = new List <string>();

            foreach (var file in all_files)
            {
                var file_short = file.Substring(dir_name.Length + 1);

                if (int.TryParse(Path.GetFileName(file_short), out int n) && file_short.Contains(Path.Combine("DEMO", "WORLDMAP", "WORLDMAP.AMB")))
                {
                    continue;
                }

                var extension_len = Path.GetExtension(file_short).Length;
                if (extension_len != 0)
                {
                    extension_len = 1;
                }

                if (good_formats.Contains(Path.GetExtension(file_short).Substring(extension_len), StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }

                suspicious_files.Add(file_short);
            }


            var cont = 1;

            if (suspicious_files.Count != 0)
            {
                cont = 0;
                var SuspiciousDialog = new Suspicious(suspicious_files.ToArray());

                var result = SuspiciousDialog.ShowDialog();

                //Continue
                if (result != DialogResult.Cancel)
                {
                    cont = 1;
                }

                if (result == DialogResult.Yes)
                {
                    foreach (var file in suspicious_files)
                    {
                        MyFile.DeleteAnyway(Path.Combine(dir_name, file));
                    }
                }
            }
            return(cont);
        }