Article View: borland.public.cppbuilder.nativeapi
Article #10409Re: Open a File with Slash in the File Path
From: Hans Galema
Date: Wed, 28 Apr 2004 07:53
Date: Wed, 28 Apr 2004 07:53
51 lines
2244 bytes
2244 bytes
PC Hua wrote:
> Sure? I'm using a library which is using fopen(). I couldn't open the
> file until I replace all '/' with '\\'.
Sure (with bcb3, so why not bcb4 up?.
Blame the library then.
Try:
void __fastcall TForm1::Button5Click(TObject *Sender)
{
AnsiString FileName = ParamStr (0);
FileName = StringReplace (
FileName, "\\", "/", TReplaceFlags() << rfReplaceAll );
if ( FileExists ( FileName ) )
ShowMessage ( FileName + "\n\nFileExists" );
else
ShowMessage ( FileName + "\n\nno FileExists" );
}
bool file_exists ( char *path )
{
FILE *stream = fopen ( path, "rb" );
if ( ! stream ) return false;
fclose ( stream );
return true;
}
void __fastcall TForm1::Button14Click(TObject *Sender)
{
AnsiString FileName = ParamStr (0);
FileName = StringReplace (
FileName, "\\", "/", TReplaceFlags() << rfReplaceAll );
if ( file_exists ( FileName.c_str() ) )
ShowMessage ( FileName + "\n\nfile_exists" );
else
ShowMessage ( FileName + "\n\nno file_exists" );
}
Hans.
Technical Details
Message-ID:
<408f6154@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.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-mailReferences:
<opr63a5edypmxkmr@newsgroups.borland.com> <408e0ec4$1@newsgroups.borland.com> <opr6407zqrpmxkmr@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,1f7c13931d096f3e X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-28 01:09:29 PST Date: Wed, 28 Apr 2004 09:53:23 +0200 From: Hans Galema <dontusethis@dontusethis.nl> User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6b) Gecko/20031208 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Open a File with Slash in the File Path References: <opr63a5edypmxkmr@newsgroups.borland.com> <408e0ec4$1@newsgroups.borland.com> <opr6407zqrpmxkmr@newsgroups.borland.com> In-Reply-To: <opr6407zqrpmxkmr@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 129.125.202.241 Message-ID: <408f6154@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1083138388 129.125.202.241 (28 Apr 2004 00:46:28 -0700) Lines: 51 Path: arc1-ca.pugleaf.net!archiver1.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