I am using the follwoing code to get all files which have txt as an
extension but I get an error that your search pattern is not correct.it
seems this fuction dosn't accept "*.txt" as search pattern.
Is there somebody can help me?
using System;
using System.IO;
class Test
{
public static void Main()
{
try
{
string[] dirs = Directory.GetFiles(@"c:\", "*.txt");
Console.WriteLine("The number of files starting with c is {0}.",
dirs.Length);
foreach (string dir in dirs)
{
Console.WriteLine(dir);
}
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
}
}