Hi,
Is it just me or does the search pattern parameter in Directory.GetFi les()
have a problem with the '?' character?
'*.*' works to find all files, but '?.*' does not work to find all files
that have only a one letter (and infinite extension size) filename. In fact,
it seems to act the same as '*.*'...
Is this by design?
Thanks in advance. 9 4622
Hi Julie,
No, it's not by design, it should work. How do you use it coz that should
work: Directory.GetFi les(<path>, "*.tx?") // or "?n.*"
Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com
JSHi,
JSIs it just me or does the search pattern parameter in
JSDirectory.Get Files()
JShave a problem with the '?' character?
JS'*.*' works to find all files, but '?.*' does not work to find all
JSfiles that have only a one letter (and infinite extension size)
JSfilename. In fact, it seems to act the same as '*.*'...
JS>
JSIs this by design?
JS>
JSThanks in advance.
JS>
What version of .Net are you using? I've just tried this in .Net 2.0 (VS
2005) and it works as expected... Only files that had exactly one character
before the point (.) were listed.
Dim listOfFiles As String() = Directory.GetFi les("C:\", "?.*")
For Each filename As String In listOfFiles
Console.WriteLi ne(filename)
Next
"Julie Smith" <ju***@home.com wrote in message
news:OP******** *****@TK2MSFTNG P02.phx.gbl...
Hi,
Is it just me or does the search pattern parameter in Directory.GetFi les()
have a problem with the '?' character?
'*.*' works to find all files, but '?.*' does not work to find all files
that have only a one letter (and infinite extension size) filename. In
fact, it seems to act the same as '*.*'...
Is this by design?
Thanks in advance.
I have constructed a string pattern for each day (DDMMYYxx.txt). So, for
example the string pattern for today is "110707xx.t xt". The search string I
use is "110707??.t xt". However, it picked up a file called "1107071.tx t". As
you can see, that only fills one ?, not both.
I find this very weird. I might do some test scripts to see if I can
reproduce it outside my application.
"Alex Meleta" <am*****@gmail. comwrote in message
news:15******** *************** ***@msnews.micr osoft.com...
Hi Julie,
No, it's not by design, it should work. How do you use it coz that should
work: Directory.GetFi les(<path>, "*.tx?") // or "?n.*"
Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com
JSHi,
JSIs it just me or does the search pattern parameter in
JSDirectory.Get Files()
JShave a problem with the '?' character?
JS'*.*' works to find all files, but '?.*' does not work to find all
JSfiles that have only a one letter (and infinite extension size)
JSfilename. In fact, it seems to act the same as '*.*'...
JSJSIs this by design?
JSJSThanks in advance.
JS>
Well, I ran two simulations:
string[] files = Directory.GetFi les(dir, "100707??.c nc",
SearchOption.Al lDirectories);
foreach (string s in files)
Console.WriteLi ne(s);
This returned:
\1007070.CNC
\10070701.CNC
\10070702.CNC
\10070703.CNC
\10070704.CNC
\10070705.CNC
\10070706.CNC
\10070707.CNC
\1007071.CNC
\1007072.CNC
As you can see, its not working as expected... However, changing the search
string to "100707?.cn c":
string[] files = Directory.GetFi les(dir, "100707?.cn c",
SearchOption.Al lDirectories);
This produces:
\1007070.CNC
\1007071.CNC
\1007072.CNC
This works as expected.
This is .NET 2.0 btw :-)
It is .net 2.0. My previous post to Alex shows my problem with it not
working when two ? are used together. Referring to your example, what if
your search string was "??.*", would it only list files with TWO characters
before the period?
"Daniel Bass" <da***********@ blueCAPSbottle. comFIRSTwrote in message
news:ek******** ******@TK2MSFTN GP02.phx.gbl...
>
What version of .Net are you using? I've just tried this in .Net 2.0 (VS
2005) and it works as expected... Only files that had exactly one
character before the point (.) were listed.
Dim listOfFiles As String() = Directory.GetFi les("C:\", "?.*")
For Each filename As String In listOfFiles
Console.WriteLi ne(filename)
Next
"Julie Smith" <ju***@home.com wrote in message
news:OP******** *****@TK2MSFTNG P02.phx.gbl...
>Hi, Is it just me or does the search pattern parameter in Directory.GetF iles() have a problem with the '?' character?
'*.*' works to find all files, but '?.*' does not work to find all files that have only a one letter (and infinite extension size) filename. In fact, it seems to act the same as '*.*'...
Is this by design?
Thanks in advance.
No. It would list files with none, one or two characters before the dot (.)
"Julie Smith" <ju***@home.com wrote in message
news:OB******** *****@TK2MSFTNG P06.phx.gbl...
It is .net 2.0. My previous post to Alex shows my problem with it not
working when two ? are used together. Referring to your example, what if
your search string was "??.*", would it only list files with TWO
characters before the period?
"Daniel Bass" <da***********@ blueCAPSbottle. comFIRSTwrote in message
news:ek******** ******@TK2MSFTN GP02.phx.gbl...
>> What version of .Net are you using? I've just tried this in .Net 2.0 (VS 2005) and it works as expected... Only files that had exactly one character before the point (.) were listed.
Dim listOfFiles As String() = Directory.GetFi les("C:\", "?.*") For Each filename As String In listOfFiles Console.WriteLi ne(filename) Next "Julie Smith" <ju***@home.com wrote in message news:OP******* ******@TK2MSFTN GP02.phx.gbl...
>>Hi, Is it just me or does the search pattern parameter in Directory.Get Files() have a problem with the '?' character?
'*.*' works to find all files, but '?.*' does not work to find all files that have only a one letter (and infinite extension size) filename. In fact, it seems to act the same as '*.*'...
Is this by design?
Thanks in advance.
On Tue, 10 Jul 2007 09:06:35 +1000, "Julie Smith" <ju***@home.com >
wrote:
>Hi, Is it just me or does the search pattern parameter in Directory.GetFi les() have a problem with the '?' character?
'*.*' works to find all files, but '?.*' does not work to find all files that have only a one letter (and infinite extension size) filename. In fact, it seems to act the same as '*.*'...
Is this by design?
Thanks in advance.
I believe it is by design. Clearly you're an old hand at the DOS
prompt where ? meant a single character as opposed to .NET where it
means zero or one
-- http://bytes.thinkersroom.com
I wrote a simple test program, and I found that ?? works like *. I dont know why.
If ? means 0 or 1 character, but why did files ending with more than 2 characters show in the results, when I searched for something like "abc??.txt" in the directory? I did not work as doc.
hello wrote:
> I wrote a simple test program, and I found that ?? works like *. I dont know why.
If ? means 0 or 1 character, but why did files ending with more than 2 characters show in the results, when I searched for something like "abc??.txt" in the directory? I did not work as doc.
Can you be more precise about exactly what you tried, and exactly what you
expected? Include a "dir" so we can see what the directory looked like. I
just tried an example, where ? and ?? did exactly what they were supposed
to.
Also, see if the "dir" command provides the same results with the same
glob.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: S. Han |
last post by:
I'm using Directory.GetFiles to enumerate files in a directory. The problem
is if you have to enumerate all files + subdirectories recursively, it takes
too much memory, and it fails.
Is there another way to enumerate files and subdirectories recursively which
doesn't take too much memory in CS?
|
by: John Smith |
last post by:
Hello all:
I am trying to search for more than one extension in a directory at the
same time with the following code:
string files = Directory.GetFiles(sDir, "*.doc*.dot");
However, this does not work nor does something like this:
string files = Directory.GetFiles(sDir, "*.doc, *.dot");
|
by: Elmo Watson |
last post by:
Is there a way, with the System.IO class, to do a recursive list of a
directory structure?
For instance, in DirectoryInfo, you have GetDirectories and GetFiles ....
In Directory, you have Directory.GetFileSystemEntries(path), but I would
like to know how to put this together, knowing which entry is a Subdirectory
and which entry is a file, and make a recursive list of the Directory
structure below a specific path - - -
|
by: Starbuck |
last post by:
Hi
When the routine below is run it gets to the line - Dim fileEntries As
String() = Directory.GetFiles(tString) and then freezes, there is no errors
etc, the program just stops responding. The path is correct and does exist
and there is a test file in there
Any thoughts please?
Private Sub InboxTimer_Tick(ByVal sender As System.Object, ByVal e As
|
by: Xagon |
last post by:
Hi,
I'm a newbie to C#, so forgive me if this is a dumb question.
What I want to do is parse a directory of IRC logfiles and dump all the .jpg
and .gif links to a text file. If I could get a single filename, I could
load it into a richedit control and do the parsing there but
Directory.GetFiles doesn't seem to do what I want.
Any tips on how to accomplisg this task?
| |
by: Michael |
last post by:
Hi,
I have been using Directory.GetFiles("g://"); in my c# application. But
now my boss want's me to do Directory.GetFiles(IP address);
I have been unable to figure out how to get this to work. Any sugestions?
Thanks,
Michael.
|
by: cjb |
last post by:
Is there a way to get Directory.GetFiles to return multi-language file names?
I haven't found any overloads that allow any such parameter. The way I am
using it now is:
foreach (string d in Directory.GetDirectories("C:\\")) {
foreach (string f in Directory.GetFiles(d, "*.exe")) {
MessageBox.Show(f);
}
}
|
by: Nathan Sokalski |
last post by:
I have an ASP.NET application which displays the directories & files in a
specified directory on the server. I use the
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to
retrieve the lists of files and directories. I have two very similar
versions of this that I am debugging, both of which use the methods
mentioned above. However, one of them is returning the contents of the
specified directory and the other is...
|
by: tshad |
last post by:
I am trying to do multiple Directory.GetFiles and append the results to one
array that I will process. I tried this:
string strFiles;
strFiles = Directory.GetFiles(SemaSettings.InputFilePath, "GL*.*");
strFiles.CopyTo(Directory.GetFiles(SemaSettings.InputFilePath,
"IN.*"),strFiles.Length-1);
strFiles.CopyTo(Directory.GetFiles(SemaSettings.InputFilePath,
"TX.*"),strFiles.Length-1,);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |