Get only unique using mask

Ant6729

Well-known member
Joined
Jan 22, 2019
Messages
56
Programming Experience
Beginner
Hello, csharpforumers)!

C#:
private void button9_Click(object sender, EventArgs e) //???????? ????? ?????? ?? ?????(????, ????? ?????? ?????? ????? ?????????? ??????)
        {
            searchMask(listBox1);
        }

        void searchMask(ListBox listBox1) // ????? ?????? ?? ?????
        {
            string rootFolder = @"C:\Users\lavraschuk\Desktop\Files";
            string pattern = @"\b(ArtId=[^a-z][^|][^,][^*][0-9]*)\b";
            using (StreamWriter sw = File.CreateText(@"C:\Users\lavraschuk\Desktop\Target\target.txt"))
            {
                foreach (var file in Directory.EnumerateFiles(rootFolder, "*.txt", SearchOption.AllDirectories))
                {
                    using (StreamReader sr = new StreamReader(file, System.Text.Encoding.Default))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            string newstring = line.Substring(0, 8);
                            Match match = Regex.Match(line, pattern, RegexOptions.IgnoreCase);
                            //string SubString = file.Substring(file.Length - 36);
                            var name = Path.GetFileName(file);

                            if (match.Success)
                            {
                                var jk = (name + " " + newstring + " " + match.Value);
                                sw.WriteLine(jk);
                            }
                            else
                                sw.Write("");
                        }
                    }
                }
            }
            MessageBox.Show("File txt is ready");
        }



I try to get unique values from txt in attach

but Imnt succeed

Could you write a correct code to do it?
 

Attachments

  • data.txt
    3.5 KB · Views: 70
Last edited by a moderator:
Please describe the actual issue. Just saying that something doesn't work isn't sufficient. What algorithm are you trying to implement? When you debugged your code, exactly where and how did its behaviour deviate from your expectation?
 

Latest posts

Back
Top Bottom