Быстрый способ заменить текст в текстовом файле. Отсюда: somename@somedomain.com: hello_world Кому: somename: hello_world
Он должен быть БЫСТРОМ и поддерживать несколько строк текстового файла.
Я попытался разбить строку на три части, нокажется медленнымПример в приведенном ниже коде.
<pre><code>
public static void Conversion()
{
List<string> list = File.ReadAllLines("ETU/Tut.txt").ToList();
Console.WriteLine("Please wait, converting in progress !");
foreach (string combination in list)
{
if (combination.Contains("@"))
{
write: try
{
using (StreamWriter sw = new
StreamWriter("ETU/UPCombination.txt", true))
{
sw.WriteLine(combination.Split('@', ':')[0] + ":"
+ combination.Split('@', ':')[2]);
}
}
catch
{
goto write;
}
}
else
{
Console.WriteLine("At least one line doesn't contain @");
}
}
}
Так что быстрый способ конвертировать каждую строку в текстовом файле от somename@somedomain.com: hello_world
To: somename:hello_world затем сохраните его в другом текстовом файле.
! Помните, что бит домена всегда меняется!