🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Split file.

#17144
From: Safari
Date: Mon, 07 Apr 2003 16:25
49 lines
2356 bytes
Hello Remy,
I wrote this code before your answer,
return me "Stream File Error..."
Where is my mistake?

Thanks,
Safari

void __fastcall TMain::BitBtn1Click(TObject *Sender)
{
    int b = 0;
    int hExten = 0;
    BYTE hBufer[1];
    int hBytes = Edit3->Text.ToInt();
    if (FileExists(Edit1->Text))
    {
       TFileStream *hSource = new TFileStream(Edit1->Text,
       fmOpenRead | fmShareDenyWrite);
       Progress->Max = hSource->Size;
       for (int a = 0; a < hSource->Size; a++)
       {
          AnsiString hName = Format("%s.%.3d", ARRAYOFCONST((
          Edit2->Text, hExten++)));
          TFileStream *hTarget = new TFileStream(hName, fmCreate);
          do
          {
             b += 1;
             Progress->Position = hSource->Position;
             hSource->ReadBuffer (hBufer, 1);
             hTarget->WriteBuffer(hBufer, 1);
          }
          while ((b = hBytes) | (b > hSource->Size));
          delete hTarget;
       }
       delete hSource;
       Progress->Position = 0;
    }
}


Remy Lebeau (TeamB) wrote:
> "Safari" <Safari@alloymail.com> wrote in message
> news:3E8F1D05.40008@alloymail.com...
> 
> 
>>How can i split a file with TFileStream?
>>I want to read Exmp:
>>1..50,000 bytes of 1,000,000 bytes to MyFile.001
>>50,001..100,000 bytes of 1,000,000 bytes to MyFile.002
Technical Details
Message-ID: <3E91A68B.8000503@alloymail.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3E8F1D05.40008@alloymail.com> <3e8f69e0@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,8f5102c5a422c5bb
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-04-07 09:37:25 PST
Message-ID: <3E91A68B.8000503@alloymail.com>
Date: Mon, 07 Apr 2003 20:55:47 +0430
From: Safari <Safari@alloymail.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Split file.
References: <3E8F1D05.40008@alloymail.com> <3e8f69e0@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.28.33.78
X-Trace: newsgroups.borland.com 1049733141 81.28.33.78 (7 Apr 2003 09:32:21 -0800)
Lines: 50
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail