473,395 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Get selected files by using GetFiles does not work as expected

Hello!

I use this static method GetFiles from the Directory class and I hope to get
only those files that have file extension ini but I get
all files that begin with ini as the file extension for example *.iniQ and
*.iniP and so on.

Directory.GetFiles(Directory.GetCurrentDirectory() , "*.ini");

Is it possible to only get those for example have *.ini as in my case.

//Tony
Nov 22 '07 #1
1 1724
"TonyJ" <jo*****************@telia.comwrote in message
news:ut**************@TK2MSFTNGP02.phx.gbl...
I use this static method GetFiles from the Directory class and I hope to
get
only those files that have file extension ini but I get
all files that begin with ini as the file extension for example *.iniQ and
*.iniP and so on.
This probably happens because you are using the NTFS filesystem with the
default option that generates MS-DOS filenames from long filenames. You can
verify this from a command prompt, typing DIR /X. For instance, create al
file "test.inip" and do a DIR /X. You will get something similar to the
following:
22/11/2007 11:29 992 TEST~1.INI test.inip

This means that the same file is recognized by the system as either
"TEST~1.INI" or "test.inip". In fact, if you type "DIR *.ini" at the command
prompt, you will see "test.inip", because its alias of "TEST~1.INI" matched
the wildcard filter.

Directory.GetFiles(Directory.GetCurrentDirectory() , "*.ini");

Is it possible to only get those for example have *.ini as in my case.
As far as I know, Directory.GetFiles does not have an option to do this
filtering automatically. You will have to loop through the returned files in
your code, removing those that do not match your criteria.

Nov 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike | last post by:
Hello All, I wrote a function that will create a file system directory for my web application and display it in the IE Treeview control. Everything wrotes great! What I'm having trouble with is...
1
by: Huahe | last post by:
Hello, Can someone help me with this problem. I select an folder using an folderbrowserdialog. I want to check if the selected folder contains any files or folders. If it does, i want to check...
3
by: Krazitchek | last post by:
Hi, how do i do to delete files with a specific extension (like *.lnk). I try File.Delete(@"e:\test\\*.lnk) but it does not work, not the good way i guess... Help please, thanks.
1
by: Prem | last post by:
Hi, I need to search a particular directory for all the files that do not have any extension and have a specific naming convension. The first 3 characters of the file name are alpha and the rest...
8
by: RML | last post by:
hey guys, i am looking at this piece of code that lists numbers of files in a directory. i want to convert it so it lists the files in th directory that end with .doc. i cant seem to get it to...
5
by: Amjad | last post by:
Hi, I want to write a For loop that will put file names of extensions (*.txt and *.csv) in an array. I had it work fine for one extension, and I need help making it work for two extensions. My...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
2
by: MichiMichi | last post by:
My asp.net application has a directory which is filled up with over 17 files (email) a second. After a while this sums up into a huge amount of files. I usually count files with the GETFILES...
15
by: Andy B | last post by:
I need to count files in a certain directory that has the string -Contract Template.xml at the end of it. How would I do this?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.