🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10397

Re: FileExists() is using wildcards

#10397
From: Remy Lebeau (TeamB)
Date: Tue, 27 Apr 2004 15:32
27 lines
1842 bytes
"Hans Galema" <dontusethis@dontusethis.nl> wrote in message
news:408e2856$1@newsgroups.borland.com...

> > Then you will have to validate the filename to see if it contains any
> > invalid characters before then testing for its existance in the file
system.

Which is simple to do.  Just call LastDelimiter() on the filename in the
places of your code where you are expectng the filename not to include
wildcards:

    AnsiString FileName = "the generated file name";

    if( FileName.LastDelimiter("\\/:*?\"<>|") != 0 )
        ShowMessage("Whoops, the generated filename contains invalid
characters!!! You better fix it.");
    else
    {
        if( FileExists ( FileName ) )
        {
            //...
        }
    }


Gambit
Technical Details
Message-ID: <408e7e7e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <408d6cad$1@newsgroups.borland.com> <408d8056$1@newsgroups.borland.com> <408e0d6a$1@newsgroups.borland.com> <408e1c4a$1@newsgroups.borland.com> <408e2856$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-27 08:40:21 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <408d6cad$1@newsgroups.borland.com> <408d8056$1@newsgroups.borland.com> <408e0d6a$1@newsgroups.borland.com> <408e1c4a$1@newsgroups.borland.com> <408e2856$1@newsgroups.borland.com>
Subject: Re: FileExists() is using wildcards
Date: Tue, 27 Apr 2004 08:32:27 -0700
Lines: 29
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: <408e7e7e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1083080318 67.22.138.253 (27 Apr 2004 08:38:38 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail