0

I fixed it ^^

private void Form2_Load(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Open Links List";
            openFileDialog1.Filter = "Text File|*.txt";
            openFileDialog1.FileName = "";
            openFileDialog1.ShowDialog();

            var file = openFileDialog1.FileName;

            if (file != "")
            {
                StreamReader read = new StreamReader(file);
                var items = read.ReadToEnd();

                string[] urls = items.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

                var count = urls.Count();

                int i = 0;
                string[] item = new String[count];
                foreach (string u in urls)
                {
                    item[i] = u.Replace("\r", String.Empty);
                    i++;
                }

                read.Close();

                string[] new_urls = RemoveDups(item);

                StreamWriter write = new StreamWriter(file);

                foreach (string u in new_urls)
                {                    
                    write.WriteLine(u);
                }

                write.Close();

            }
        }

        public string[] RemoveDups(string[] s)
        {
            return s.Distinct().ToArray<String>();
        }
0

Hmm.. it works yes, but not for like 10k rows or so.. is there a way to remove duplicates from 100k+ items?

0

It should work for any number of items, but remember that the more items there are, the longer it takes to run the operation.

0

You will need to write your own method to do that. You can write an extension method and/or use regular expressions.

0

Yeah, that's a great idea, but have you any idea how I compare everything ?

0

So long as you know that the string will always be a URL, you should be able to get the Substring by finding the index of the 3rd forward slash.

0

So long as you know that the string will always be a URL, you should be able to get the Substring by finding the index of the 3rd forward slash.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.