1
How can I list files .txt which contains numbers of telephones in that format (99)99999-9999 cellular and (99)9999-9999 fixed ?
This is the code I’ve made so far, just need to find inside the file . txt the string in the format of a phone:
private static void ListarArquivos()
{
try
{
string[] _diretorios = Directory.GetDirectories(@"D:\Arquivos\");
Console.WriteLine("LSITA DE DIRETÓRIOS: ");
Console.WriteLine("");
foreach (string dir in _diretorios)
{
Console.WriteLine(dir);
string[] arrArquivos = Directory.GetFiles(dir, "*.txt");
for (int x=0; x < arrArquivos.Length; x++)
{
if (File.Exists(arrArquivos[x]))
{
using (StreamReader sr = new StreamReader(arrArquivos[x]))
{
string linha;
while ((linha = sr.ReadLine()) != null)
{
Console.WriteLine(linha);
}
}
}
else
{
Console.WriteLine(" O arquivo " + arrArquivos[x] + "não foi localizado !");
}
Console.WriteLine("");
}
}
Console.ReadKey();
}
catch
{
throw;
}
}
Example txt file, I want that NAY list the arquivo2.txt Why don’t you have a phone number:
Example of file 1.txt:
55(11)97387-0245
ORGANIZATIONS LTDA
55(11)99678-3199
55(11)97100-0445
MARIA JOSÉ DA SILVA
Example of file 2.txt:
JOÃO DA SILVA
ORGANIZATIONS LTDA
STAR BAKERY
QUITANDA 2 BROTHERS
MARIA JOSÉ DA SILVA
Example of file 3.txt:
(11)5489-9873
ORGANIZATIONS LTDA
PADARA ESTRELA
(11)5489-5912
MARIA JOSÉ DA SILVA
you would have some lines from your file to show?
– Tiedt Tech
@Tiedt Tech edited the post and inserted example of txt files
– hard123
worked my answer?
– Tiedt Tech
Good morning @Tiedt Tech worked yes. Thank you.
– hard123