How to Remove Duplicate Donmain?

  • Автор темы Автор темы linda2013
  • Дата начала Дата начала
Anyone can help me?
 
Stuck at the first breakpoint.
Not sure whether it's caused by the bind function.( Don't know list bind very well.)

Basic outline is there. Not c#. Slowly.
 

Вложения

  • D.7z
    D.7z
    64 KB · Просмотры: 336
Optimize version with C# code.
Result in file FinalUrl.txt

Test
File Dup1.txt, 3 Urls (all duplicates) => 1 Url in FinalUrl.txt
File Dup2.txt, 1692 Urls => 810 Urls in FinalUrl.txt

C# Code
Код:
Развернуть Свернуть Копировать
System.Collections.Hashtable distinctHosts = new System.Collections.Hashtable();
var fileUrl = project.Variables["FileUrl"].Value;
int count = Convert.ToInt32(Macros.FileSystem.FileCountOfLines(fileUrl));

for(int i = 0; i < count; i++)
{
    var url = Macros.FileSystem.FileGetLine(fileUrl, i.ToString(), false);
    System.Uri uri = new Uri(url);
    if (!distinctHosts.ContainsKey(uri.Host)) { distinctHosts.Add(uri.Host, uri.ToString()); }
}

string[] uniqUrl = new string[distinctHosts.Count];
distinctHosts.Values.CopyTo(uniqUrl, 0);
return string.Join("\n", uniqUrl);
 

Вложения

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)