DELPHI切割文件代码
来源:互联网 发布:网络协同 系统架构 编辑:程序博客网 时间:2024/04/30 01:45
//Splitting Files
procedure TForm1.Button1Click(Sender: TObject);
var
i, WantedFragSize, RealToWrite : Integer;
InStream, OutStream : TFileStream;
S : String;
begin
if Opendialog1.Execute then
begin
SaveDialog1.Title := 'Select Dir and input FilePrefix without Suffix';
If SaveDialog1.Execute then
begin
WantedFragSize := StrtoInt(Edit1.Text); //Wanted SplitSize
i := 0;
InStream := TFileStream.Create(OpenDialog1.FileName, fmOpenRead );
try
while (InStream.Position < InStream.Size) do
Begin
s := IntToStr(I); //Building numeric suffix
while Length(s) < 3 do s := '0'+s;
s := '.'+s;
If InStream.Size - InStream.Position < WantedFragSize then
RealToWrite := InStream.Size - InStream.Position
else
RealToWrite := WantedFragSize;
OutStream := TFileStream.Create(SaveDialog1.FileName+ s,fmCreate );
try
OutStream.CopyFrom(InStream,RealToWrite) ;
Inc(i);
finally
OutStream.Free;
end;
end;
Finally
InStream.Free;
end;
end;
end;
end;
//concanating files
procedure TForm1.Button2Click(Sender: TObject);
var
i : Integer;
InStream, OutStream : TFileStream;
SourcePath, FragName, S : String;
begin
Opendialog1.Title := 'Select any Fragmented File';
if Opendialog1.Execute then
begin
SourcePath := ExtractFilePath(Opendialog1.FileName);
FragName := ExtractFileName(Opendialog1.FileName);
SaveDialog1.Title := 'Select Dir and input the FileName with Suffix';
If SaveDialog1.Execute then
begin
i := 0;
s := IntToStr(I);
while Length(s) < 3 do s := '0'+s;
s := '.'+s;
FragName := ChangeFileExt(FragName, s);
If FileExists(SourcePath+FragName) then
begin
OutStream := TFileStream.Create(Savedialog1.FileName, fmCreate);
try
While FileExists(SourcePath+FragName) do
Begin
InStream := TFileStream.Create(SourcePath+FragName,f mOpenRead) ;
try
OutStream.CopyFrom(InStream,0);
Inc(i);
s := IntToStr(I);
while Length(s) < 3 do s := '0'+s;
s := '.'+s;
FragName := ChangeFileExt(FragName, s);
finally
InStream.Free;
end;
end;
finally
OutStream.Free;
end;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i, WantedFragSize, RealToWrite : Integer;
InStream, OutStream : TFileStream;
S : String;
begin
if Opendialog1.Execute then
begin
SaveDialog1.Title := 'Select Dir and input FilePrefix without Suffix';
If SaveDialog1.Execute then
begin
WantedFragSize := StrtoInt(Edit1.Text); //Wanted SplitSize
i := 0;
InStream := TFileStream.Create(OpenDialog1.FileName,
try
while (InStream.Position < InStream.Size) do
Begin
s := IntToStr(I); //Building numeric suffix
while Length(s) < 3 do s := '0'+s;
s := '.'+s;
If InStream.Size - InStream.Position < WantedFragSize then
RealToWrite := InStream.Size - InStream.Position
else
RealToWrite := WantedFragSize;
OutStream := TFileStream.Create(SaveDialog1.FileName+
try
OutStream.CopyFrom(InStream,RealToWrite)
Inc(i);
finally
OutStream.Free;
end;
end;
Finally
InStream.Free;
end;
end;
end;
end;
//concanating files
procedure TForm1.Button2Click(Sender: TObject);
var
i : Integer;
InStream, OutStream : TFileStream;
SourcePath, FragName, S : String;
begin
Opendialog1.Title := 'Select any Fragmented File';
if Opendialog1.Execute then
begin
SourcePath := ExtractFilePath(Opendialog1.FileName);
FragName := ExtractFileName(Opendialog1.FileName);
SaveDialog1.Title := 'Select Dir and input the FileName with Suffix';
If SaveDialog1.Execute then
begin
i := 0;
s := IntToStr(I);
while Length(s) < 3 do s := '0'+s;
s := '.'+s;
FragName := ChangeFileExt(FragName, s);
If FileExists(SourcePath+FragName) then
begin
OutStream := TFileStream.Create(Savedialog1.FileName,
try
While FileExists(SourcePath+FragName) do
Begin
InStream := TFileStream.Create(SourcePath+FragName,f
try
OutStream.CopyFrom(InStream,0);
Inc(i);
s := IntToStr(I);
while Length(s) < 3 do s := '0'+s;
s := '.'+s;
FragName := ChangeFileExt(FragName, s);
finally
InStream.Free;
end;
end;
finally
OutStream.Free;
end;
end;
end;
end;
end;
- DELPHI切割文件代码
- c++切割文件的代码
- 文件操作delphi代码
- delphi版MP3切割
- delphi字符串切割
- 文件切割
- DELPHI 递归遍历文件代码
- Delphi 代码文件你结构
- delphi 拷贝网络共享文件 代码
- 文件切割/合并工具
- 文件切割子程序
- 文件切割脚本
- 文件切割方法
- txt文件切割器
- linux 文件切割
- 文件切割总结
- Java切割文件
- java文件切割
- 今天我偷看了我家存折……(主要看精彩回复)
- QuickSort实现
- ASP常用函数表
- MergeSort的实现
- 在JSP页面中轻松实现数据饼图
- DELPHI切割文件代码
- ASP写的链表Class,不太实用,就当练习写Class了。
- JSP实现论坛树型结构的具体算法
- 乐悲篇
- BinarySearch的实现
- 在JSP中使用JavaMail
- C的一些简单习题(9)--牛顿迭代法求根
- 数据库连接字符串大全
- 这个圣诞里不应该有我的快乐