I have a directory of 27 files. The files end in either 1.txt, 2.txt,
3.txt, or 4.txt.
If I say:
For Each filename As String In
Directory.GetFi les("C:\TSA\DOW NLOADS\TRX\PERF ORMANCE_DATA\DO WNLOAD\",
"*1.TXT")
Debug.WriteLine (filename)
Next
It prints out the following:
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\E310920041.tx t
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\E311020041.tx t
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 44.txt
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 42.txt
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 43.txt
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736807200 41.txt
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 41.txt
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R701360207200 41.txt
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R703090108200 41.txt
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R703320909200 41.txt
Obviously, this is not correct. If my search string is "*2.TXT", "*3.TXT",
or "*4.TXT" it prints out alright. Has anyone seen this behavior before in
Directory.GetFi les?
-Jason 2 1909
The odd part is, if I change the code to:
Dim sFiles() As String =
Directory.GetFi les("C:\TSA\DOW NLOADS\TRX\PERF ORMANCE_DATA\DO WNLOAD\",
"*.txt")
For Each filename As String In sFiles
If filename.EndsWi th("1.txt") Then Debug.WriteLine (filename)
Next
Then it prints out the correct information. Why would a search string of
*1.txt return things that don't end in 1.txt?
"OpticTygre " <op********@ade lphia.net> wrote in message
news:JY******** ************@ad elphia.com... I have a directory of 27 files. The files end in either 1.txt, 2.txt, 3.txt, or 4.txt.
If I say:
For Each filename As String In Directory.GetFi les("C:\TSA\DOW NLOADS\TRX\PERF ORMANCE_DATA\DO WNLOAD\", "*1.TXT") Debug.WriteLine (filename) Next
It prints out the following:
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\E310920041.tx t C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\E311020041.tx t C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 44.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 42.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 43.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736807200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R701360207200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R703090108200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R703320909200 41.txt
Obviously, this is not correct. If my search string is "*2.TXT", "*3.TXT", or "*4.TXT" it prints out alright. Has anyone seen this behavior before in Directory.GetFi les?
-Jason
Optic,
All of the "wrong" files have long file names, which suggests to me that
their short file name might be something ~1, which would match the *1.TXT".
You can use "dir /x" under the Command Prompt to see the 8.3 file names.
Unfortunately I don't know of any workarounds other then checking the names
returned from Directory.GetFi les. Note this is not to suggest there are not
other ways of limiting the search to long names...
Hope this helps
Jay
"OpticTygre " <op********@ade lphia.net> wrote in message
news:JY******** ************@ad elphia.com... I have a directory of 27 files. The files end in either 1.txt, 2.txt, 3.txt, or 4.txt.
If I say:
For Each filename As String In Directory.GetFi les("C:\TSA\DOW NLOADS\TRX\PERF ORMANCE_DATA\DO WNLOAD\", "*1.TXT") Debug.WriteLine (filename) Next
It prints out the following:
C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\E310920041.tx t C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\E311020041.tx t C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 44.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 42.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 43.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736807200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\HEI1736809200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R701360207200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R703090108200 41.txt C:\TSA\DOWNLOAD S\TRX\PERFORMAN CE_DATA\DOWNLOA D\R703320909200 41.txt
Obviously, this is not correct. If my search string is "*2.TXT", "*3.TXT", or "*4.TXT" it prints out alright. Has anyone seen this behavior before in Directory.GetFi les?
-Jason 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: 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: =?Utf-8?B?RGFuaWVsIENvcnLDqmE=?= |
last post by:
Hi,
I've been trying to use Directory.GetFiles() and also
DirectoryInfo.GetFiles() to list files on a remote server using
"\\server_name\dir_name" like paths. It works fine on a test windows app, but
I get an access error message when the code is running on a asp.net app.
First I thought it was just a matter of credentials, so I started to use
windows authentication and impersonate the current user, but I still got the
same message.
|
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: Michael Jackson |
last post by:
In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path) to
get all the files in the directory. However, I'm getting an error regarding
"Illegal character in Path", even though I can copy, etc the file using the
Windows XP explorer.
I can trap the error, but then this traps the entire GetFiles() function,
not just the one bad file.
Is there a way to just trap for the one bad file and continue on?
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |