Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Files

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I need to find a file in code.
I went to:

Which says that you can find a file, and here's how to do it, but you can't tell it what file to find. I need to find an executable so I can run it inside of my program. The running part is not the problem, its the finding part. If there's anyone who could help me out here, I would appreciate it.
Thanks, Cyprus
 
In Borland there are routines exactly for that purpose in the Library.

I think the Names are "findfirst" and "findnext"


hnd
hasso55@yahoo.com

 
Somewhere in this forum, I posted some code that showed how to use findfirst and findnext. That was a couple of years ago. If you can't find it, post here and I'll repost it. Also, VCL has FindFirst and FindNext. You should be able to find examples for these in your help files. James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that they think I am now
qualified to do anything with nothing.
 
I looked for the post, but couldn't find it. I tried FindFirst from the VCL but it's not an easy tool to work with. I'd appreciate it if you could repost that code for me.
Thanks, Cyprus
 
This should help, I'm actually using this code in my current project. Theres some other code mixed in here (copy functions) but just take what you need.

TSearchRec sr;
String sSearchResult;
FILE *fpFp;
FILE *fpOp;
// file path goes in text box
char _command[400];
sprintf(_command, "copy Original.dat New.dat");
system(_command);
//replace PathTOSearchFor with your path
//replace .txt with the file extensions
FindFirst("PathTOSearchFor*.Txt*", faAnyFile, sr);
sSearchResult = sr.Name;

fpFp = fopen("New.dat", "a");
String NullChecker = sSearchResult.SubString(1,1);

if (NullChecker != "" && NullChecker != NULL)
fprintf(fpFp, "\t%s\n", sSearchResult.SubString(1,6));
FindNext(sr);
do
{
sSearchResult = sr.Name;
if (NullChecker != "" && NullChecker != NULL)
fprintf(fpFp, "\t%s\n", sSearchResult.SubString(1, 6));
}
while (FindNext(sr) == 0);
fclose(fpFp);
FindClose(sr);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top