Article View: borland.public.cppbuilder.nativeapi
Article #10385Re: FileExists() is using wildcards
From: Remy Lebeau (TeamB)
Date: Mon, 26 Apr 2004 21:28
Date: Mon, 26 Apr 2004 21:28
37 lines
2183 bytes
2183 bytes
"Hans Galema" <dontusethis@dontusethis.nl> wrote in message
news:408d6cad$1@newsgroups.borland.com...
> There was a '?' in a FileName that was generated
> by code. The '?' was interpreted as a wildcard.
"?" is an invalid character for filenames.
> AnsiString FileName = "Unit1.?";
>
> if ( FileExists ( FileName ) ) // This will find Unit1.cpp or Unit1.h
You can't do wildcard matching like that. FileExists() does not support
wildcards at all. If you need that, then use FindFirst() instead:
TSearchRec sr;
if( FindFirst("drive:\\path\\" + FileName, faAnyFile & ~faDirectory, sr)
== 0 )
{
// sr contains the first fileame that matched the wildcard mask.
// If multiple files match the mask, you will have to decide which
// specific file you actually want to load. Use FindNext() in a
// loop to get the remaining matching filenames.
FindClose(sr);
}
else
// no matching filenames found...
> Memo1->Lines->LoadFromFile ( FileName ); // exeption!
You can't load a filename with wildcards in it. You need to specify the
EXACT file to load.
Gambit
Technical Details
Message-ID:
<408d8056$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<408d6cad$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,8374fb71f8a662f4 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-26 14:39:28 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <408d6cad$1@newsgroups.borland.com> Subject: Re: FileExists() is using wildcards Date: Mon, 26 Apr 2004 14:28:07 -0700 Lines: 39 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <408d8056$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1083015254 67.22.138.253 (26 Apr 2004 14:34:14 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail