开发学院软件开发VC FTP多线程切割传输 阅读

FTP多线程切割传输

 2008-09-23 19:27:14 来源:WEB开发网   
核心提示:1.数据分割和合并,采用流文件 unitUnitPhotoData;interfaceusesWindows,SysUtils,Variants,Classes,StdCtrls;typeTPhotoData=class(TObject)private{Privatedeclarations}publicprocedu

1.数据分割和合并,采用流文件

unitUnitPhotoData;
interface
uses
 Windows,SysUtils,Variants,Classes,StdCtrls;
type
 TPhotoData=class(TObject)
 private
  {Privatedeclarations}
 public
  procedureSplitData(aFileName:string;aDataSize:integer;
            aFileNameList:TStrings);
  procedureCompoundData(aHeadFileName:string);
  {Publicdeclarations}
 end;
implementation
{TPhotoData}
procedureTPhotoData.SplitData(aFileName:string;aDataSize:integer;
               aFileNameList:TStrings);
var
 i,aRealSize:Integer;
 InStream,OutStream:TFileStream; 
 s:string;
begin
 i:=0;
 InStream:=TFileStream.Create(aFileName,fmOpenRead);
 try
  while(InStream.Position<InStream.Size)dobegin
   s:=IntToStr(i);
   whileLength(s)<3dos:='0'+s;
   s:='.'+s;
   aFileNameList.Add(aFileName+s);
   ifInStream.Size-InStream.Position<aDataSizethen
    aRealSize:=InStream.Size-InStream.Position
   else
    aRealSize:=aDataSize;
    OutStream:=TFileStream.Create(aFileName+s,fmCreate);
    try
    OutStream.CopyFrom(InStream,aRealSize);
    Inc(i);
    finally 
    OutStream.Free;
    end;
  end;
 finally
  InStream.Free;
 end;
end;
procedureTPhotoData.CompoundData(aHeadFileName:string);
var
 i:Integer;
 InStream,OutStream:TFileStream;
 ExtName,s:string;
begin
 i:=0;
 s:=IntToStr(I);
 whileLength(s)<3dos:='0'+s;
  s:='.'+s;
  ExtName:=ChangeFileExt(ExtName,s);
  ifFileExists(aHeadFileName+ExtName)thenbegin
   OutStream:=TFileStream.Create(aHeadFileName,fmCreate);
   try
    whileFileExists(aHeadFileName+ExtName)dobegin
     InStream:=TFileStream.Create(aHeadFileName+ExtName,fmOpenRead);
     try 
      OutStream.CopyFrom(InStream,0);
      Inc(i);
      s:=IntToStr(I);
      whileLength(s)<3dos:='0'+s;
      s:='.'+s;
      ExtName:=ChangeFileExt(ExtName,s);
     finally
      InStream.Free;
     end;
    end;
  finally
   OutStream.Free;
  end;
 end;
end;
end.

1 2  下一页

Tags:FTP 线程 切割

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接