473,396 Members | 1,933 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,396 software developers and data experts.

Search for File (how to)

Hello. Anyone know how to use the FileInfo class to search for a specific
file in a directory? My problem is the specific file I am looking for, but
the actual filename can contain alot of extra characters that are created
when a batch process takes place. for example, I know the root path and the
first few letters of the filename.

Root: C:\TestFolder
1st File to iterate: SThompson.123.exit.Read.out
2nd File to iterate: SThompson.email.Lg334.ini
OtherFile: SThompson.gif

So the information I have, stored in exposed public properties are the first
and last name (S Thompson)

The goal is to look for the .INI file ONLY. The problem is the rest of the
characters between the SThompson and the .INI change constantly b/c of batch
processing. Here is example I can think of

{
...... //path argument is stored from XML file

SomeClass sClass = new SomeClass
sClass.ReadFile() // method gets the properties
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] files2 = diSftp.GetFiles(i._Fname.Substring(1, 1).Trim +
i._Lname, "*.out);

May 8 '06 #1
1 1651
You have the right idea .. just build up your path ...

SThompson*.ini should be able to get the file ...

You may also want to look at returning all the files and using a regexp
filter on the filenames returned which can be much more flexible than a
simple wildcarded filename

Cheers,

Greg Young
MVP - C#

"Toco" <To**@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
Hello. Anyone know how to use the FileInfo class to search for a specific
file in a directory? My problem is the specific file I am looking for,
but
the actual filename can contain alot of extra characters that are created
when a batch process takes place. for example, I know the root path and
the
first few letters of the filename.

Root: C:\TestFolder
1st File to iterate: SThompson.123.exit.Read.out
2nd File to iterate: SThompson.email.Lg334.ini
OtherFile: SThompson.gif

So the information I have, stored in exposed public properties are the
first
and last name (S Thompson)

The goal is to look for the .INI file ONLY. The problem is the rest of
the
characters between the SThompson and the .INI change constantly b/c of
batch
processing. Here is example I can think of

{
..... //path argument is stored from XML file

SomeClass sClass = new SomeClass
sClass.ReadFile() // method gets the properties
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] files2 = diSftp.GetFiles(i._Fname.Substring(1, 1).Trim +
i._Lname, "*.out);


May 8 '06 #2

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

Similar topics

6
by: Alan | last post by:
I want to search a string in a file, but I don't know the position, how can I search the string and stop at that line containing that string ? for example, I want to seach the string ".ABC" in a...
3
by: jdworley | last post by:
Howdy! The search is a 1 GB+ file from a crash to be exact - had an e-mail correspondence (window) hopefully in it so I saved the file on reboot before windoze kicked in and want to open and...
4
by: Nikos | last post by:
Hi... I would like to search for a hex string (for example: "E903") inside a binary file... Although I open the file correctly, how do I search hex values? Thanks in advance! Nikos
1
by: Filip | last post by:
Hi All, a while ago I had to write a asp.net search application. The start page is a html page, which calls a aspx file that shows the search results, using a datagrid. So far no problem. But:...
1
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly...
13
by: Ray Muforosky | last post by:
Hello all: Task: I want to do file search, using the "conatining text" option from a web page. How do I search for a file on my local drive containing a certain string, from a web page. That...
8
by: stunna | last post by:
Hi there, i want to implement a a system to search for a file in a folder using the file name and if its there, i want it to be displayed. I have one through a couple of books on how to implement...
1
by: nganglove | last post by:
C++ string search -------------------------------------------------------------------------------- Hello, please can any one help me? I am given an assigment in C++ to read a text file and...
4
by: ravindarjobs | last post by:
hi...... i am using ms access 2003,vb6 i have a form. in that i have 2 buttons 1. start search 2 stop search when i click the "start search" button the fucntion SearchSystem() is called,...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
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...
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
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
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...
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.