Hi, All:
Previously, i made a program using d5. It works well in xp. But when i recently build it again in d7, many problems appear. Below is one of them.
When executing in d7, this chop file function prompts I/O 123 error? why ? Please help.
Thank you in advance.
*************
function Tform1.SplitFile(FileName : TFileName; SizeofFiles : Integer) : Boolean;
var
i : Word;
fs, sStream: TFileStream;
SplitFileName: String;
abc,a,ext,dir,path,newfile:string;
begin
fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
abc:=extractfilename(filename);
a:=extractfileext(abc);
dir:=stringreplace(abc,a,'',[rfReplaceAll, rfIgnoreCase]);
createdir(extractfiledir(filename)+'\'+dir);
path:=extractfiledir(filename)+'\'+dir+'\';
filelistbox2.Directory:=path;
try
panel43.visible:=true;
gauge54.minvalue:=0;
gauge54.maxvalue:=trunc(fs.Size / SizeofFiles)+1;
for i := 1 to Trunc(fs.Size / SizeofFiles) + 1 do
begin
panel42.caption:='Chopping '+inttostr(i);
gauge54.progress:=i;
application.processmessages;
SplitFileName := ChangeFileExt(FileName, '.'+ FormatFloat('000', i));
newfile:= path+extractfilename(splitfilename);
sStream := TFileStream.Create(newfile, fmCreate or fmShareExclusive);
try
if fs.Size - fs.Position < SizeofFiles then
SizeofFiles := fs.Size - fs.Position;
sStream.CopyFrom(fs, SizeofFiles);
finally
sStream.Free;
end;
end;
finally
fs.Free;
end;
panel42.caption:='Chop Complete';
panel46.caption:='Save in: '+path;
panel43.visible:=false;
drivecombobox1.Update;
directorylistbox1.Update;
filelistbox2.Update;
filelistbox1.update;
end;
*******************