assignfile (inf, 'input file');
reset (inf, 1);
size := fileSize (inf);
repeat
showMessage (enter floppy in "A") { or "B" or allow them to specify }
assignFile (outf, 'A:output file');
rewrite (outf, 1);
outsize := diskFree (1); { or 2 if it's the "B" drive }
while (outsize > 0) and (size > 0) do begin
amt := sizeof(buf);
if amt > outsize then amt := outsize;
blockRead (inf, buf, amt, amtRead);
blockWrite (outf, buf, amtRead);
dec (outSize, amtRead);
dec (size, amtRead);
end;
closeFile (outf);
until size <= 0;
closeFile (inf);
This is OTTOMH, syntax hasn't been checked, etc. You may want to add other
code to let the user specify the "A" or "B" drive, and/or a naming scheme so
that if disks get out of order it's trapped.
Re-assembling the files is similar: open outf on the hard disk, ask the user
for the first floppy, blockRead/blockWrite from the floppy to the hard disk,
then ask the user for the next floppy, etc. until all floppies are read.
Procedure
var
dlg: TBrowseForFolderDialog;
DestPath:string;
begin
dlg := TBrowseForFolderDialog.Create;
dlg.Title := '请选取目标文件夹:';
if dlg.Execute then
begin
DestPath := dlg.Path;
end;
dlg.Free;
end;
4.开始切割
根据上边步骤的选择,确定了待切割的原始文件,切割大小和存放位置,下边就可以开始了。
首先我们用一个“文件流”以只读方式打开原始文件
var
fs:TFileStream;
begin
fs:=TfileStream.create(“文件名称”,fmOpenRead)
……………
然后我们创建一个“内存流”
var
ms:TmemoryStream;
begin
ms:=TmemoryStream.create;
……………
根据文件切割的大小计算字节数,从“文件流”中向“内存流”中拷贝指定的大小,将内存流存储到目标文件夹下,文件扩展名累计创建(方便合并)
分析切割大小:
case rdgCut.ItemIndex of
0: filesize := 2000 * 1024; //2000 K
1: filesize := 1440 * 1024; //1440 K
2: filesize := 1200 * 1024; //1200 K
3: filesize := 1000 * 1024; //1000 K
4: filesize := 720 * 1024; //720 K
5: filesize := 500 * 1024; //500 K
6: filesize := 300 * 1024; //300 K
7: filesize := 200 * 1024; //200 K
else filesize := 100 * 1024; //100 K