Article View: borland.public.cppbuilder.nativeapi
Article #17073Re: Split file.
From: Safari
Date: Sat, 12 Apr 2003 03:45
Date: Sat, 12 Apr 2003 03:45
65 lines
3014 bytes
3014 bytes
Hello again Remy,
I say my source return error, not your source.
My source here is:
Procedure TMain.BitBtn3Click(Sender: TObject);
Var hSource, hTarget: TFileStream; hChoose: String;
hBuf: Byte; hBin, hExt, hInt: Integer; hLen: Longint;
Begin
hBin := 0;
hExt := 0;
hLen := StrToInt(Edit3.Text);
hSource := TFileStream.Create(Edit1.Text, fmOpenRead
or fmShareDenyWrite);
Progress.Max := hSource.Size;
for hInt := 0 to hSource.Size - 1 do
Begin
Inc(hExt);
hChoose := Format('%s.%.3d', [Edit2.Text, hExt]);
hTarget := TFileStream.Create(hChoose, fmCreate);
Repeat
Inc(hBin);
hSource.ReadBuffer (hBuf, 1);
hTarget.WriteBuffer(hBuf, 1);
Progress.Position := hSource.Size;
Until hBin = hLen;
hTarget.Free;
End;
hSource.Free;
Progress.Position := 0;
End;
-------------------------------------------------------------------------
void __fastcall TMain::BitBtn1Click(TObject *Sender)
{
BYTE hBuf;
int hBin = 0;
int hExt = 0;
int hLen = 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++)
{
hExt++;
AnsiString hName = Format("%s.%.3d", ARRAYOFCONST((Edit2->Text,
hExt)));
TFileStream *hTarget = new TFileStream(hName, fmCreate);
do
{
hBin++;
hSource->ReadBuffer (&hBuf, 1);
hTarget->WriteBuffer(&hBuf, 1);
Progress->Position = hSource->Position;
}
while (hBin != hLen);
delete hTarget;
}
delete hSource;
Progress->Position = 0;
}
}
Thanks a lot,
Safari
Technical Details
Message-ID:
<3E978BC8.2020907@alloymail.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3E8F1D05.40008@alloymail.com> <3e8f69e0@newsgroups.borland.com> <3E955473.6000807@alloymail.com> <3e9619fe$1@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-11 21:02:37 PST Message-ID: <3E978BC8.2020907@alloymail.com> Date: Sat, 12 Apr 2003 08:15:12 +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> <3E955473.6000807@alloymail.com> <3e9619fe$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.28.33.79 X-Trace: newsgroups.borland.com 1050119891 81.28.33.79 (11 Apr 2003 20:58:11 -0700) Lines: 66 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail