Hello, csharpforumers)!
I try to get unique values from txt in attach
but Imnt succeed
Could you write a correct code to do it?
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
Last edited by a moderator: