Hi
How can I get the files in a folder - but only certain file types eg only txt file?
Thanks
Printable View
Hi
How can I get the files in a folder - but only certain file types eg only txt file?
Thanks
Edit:Code:DirectoryInfo dir = new DirectoryInfo("C:\\");
FileInfo[] f = dir.GetFiles("*.txt");
foreach(FileInfo t in f){
Console.WriteLine(t.Name);
}
I have to stop putting C# code in the VB.Net section
VB Code:
Dim dir As DirectoryInfo = New DirectoryInfo("C:\") Dim f As FileInfo() = dir.GetFiles("*.txt") For Each t As FileInfo In f Console.WriteLine(t.Name) Next
I've got an odd problem. When I use:
dir.GetFiles("2003*.*")
one of my results is:
2011001XEAP_1_1.837
This also happens in a command line dir search. Any idea?
????
I created this file at home (using XP Pro), and dir does not return filenames that do not match. I'm using 2000 Pro at work. Is this a bug, or am I missing something simple?
hmm... I created two files.... "2011001XEAP_1_1.837" and "2003001XEAP_1_1.837"
only the latter came up in both.
are these the names including the extension?
I think it has something to do with the number of files in the directory. 837 is the file extension.