FTP多线程切割传输
2008-09-23 19:27:14 来源:WEB开发网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.
- ››线程状态图
- ››FTP基础知识及模式精解
- ››FTP服务器如何实现安全性(上)
- ››FTP服务器如何实现安全性(下)
- ››FTP服务器完全手册
- ››FTP服务器的排错详解
- ››FTP与VSFTP
- ››FTP命令基本用法
- ››FTP服务器的攻防实战
- ››FTP多线程切割传输
- ››FTP服务器安全防范及数据备份
- ››FTP服务器架设的三方面安全因素
更多精彩
赞助商链接