Como posso listar arquivos .txt que contenha números de telefones nesse formato (99)99999-9999 celular e (99)9999-9999 fixo ?
Esse é o código que fiz até agora, só falta encontrar dentro do arquivo .txt a string no formato de um telefone:
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;
}
}
Exemplo de arquivo txt, quero que NÃO liste o arquivo2.txt por que não tem numero de telefone:
Exemplo do arquivo1.txt:
55(11)97387-0245
ORGANIZAÇÕES LTDA
55(11)99678-3199
55(11)97100-0445
MARIA JOSÉ DA SILVA
Exemplo do arquivo2.txt:
JOÃO DA SILVA
ORGANIZAÇÕES LTDA
PADARIA ESTRELA
QUITANDA 2 IRMÃOS
MARIA JOSÉ DA SILVA
Exemplo do arquivo3.txt:
(11)5489-9873
ORGANIZAÇÕES LTDA
PADARA ESTRELA
(11)5489-5912
MARIA JOSÉ DA SILVA