Article View: borland.public.cppbuilder.nativeapi
Article #14419Re: FileCreate function problem
From: Jonathan Arnold
Date: Wed, 13 Aug 2003 12:51
Date: Wed, 13 Aug 2003 12:51
43 lines
2991 bytes
2991 bytes
Plese follow newsgroup guidelines and avoid overquoting. Just
include the lines you need to give your reply context.
http://www.borland.com/newsgroups/ - Borland newsgroup descriptions
http://www.borland.com/newsgroups/netiquette.html - netiquette
BTW, here's a good page that describes the "evils" of top-posting:
http://www.caliburn.nl/topposting.html
>>>>> if(!FileExists("c:\CProjects\test.txt"))
>>>>> {
>>>>> if(!FileCreate("c:\CProjects\test.txt"))
>>>>> {
>>>>> TStringList *Sample1 = new TStringList();
>>>>> Sample1->LoadFromFile("c:\CProjects\test.txt"); // Error
>>>>> }
>>>>> }
>>>>>
This code is just all wrong:
1 - As pointed out earlier, you need to double up on the slashes. You said
it was a mistype - please just copy and paste your code in the future to
be sure we're all working on the same problem:-)
2 - FileExists returns false if the file doesn't exist. You say you see
it in Explorer after running, so you know it exists. Have you deleted it
first, before running? Because otherwise this code will never run.
3 - FileCreate returns a -1 on error, and a positive value if it succeeds.
So your test should be : if ( FileCreate(...) != -1 ). Be sure to read
the docs before using an API call.
4 - You mention your receive an error about not being able to open 'test.tct'
(sic). Again, we need to get the *exact* code you are using. Maybe you simply
have a typo?
--
Jonathan Arnold C/C++/CBuilder Keen Advice:
http://www.keen.com/categories/categorylist_expand.asp?sid=5156620
Comprehensive C++Builder link site:
http://www.buddydog.org/C++Builder/c++builder.html
Technical Details
Message-ID:
<3f3a343e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f3989ee@newsgroups.borland.com> <3f398d1f$1@newsgroups.borland.com> <3f398d79@newsgroups.borland.com> <3f39f7a6$1@newsgroups.borland.com> <3f3a1241@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5967b7894a1d3380 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-13 06:12:02 PST Date: Wed, 13 Aug 2003 08:51:08 -0400 From: Jonathan Arnold <jdarnold@buddydog.org> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en, ja MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: FileCreate function problem References: <3f3989ee@newsgroups.borland.com> <3f398d1f$1@newsgroups.borland.com> <3f398d79@newsgroups.borland.com> <3f39f7a6$1@newsgroups.borland.com> <3f3a1241@newsgroups.borland.com> In-Reply-To: <3f3a1241@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 66.92.76.225 Message-ID: <3f3a343e$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1060779070 66.92.76.225 (13 Aug 2003 05:51:10 -0700) Lines: 44 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail