文件分割器的代码
2008-02-23 07:22:45来源:互联网 阅读 ()
语 种:简体中文
编辑器:D5-7
平 台:Win9x,Win2k/NT,WinXP
作品源代码: -
软件或演示: -
代码大小: -
软件大小: -
无图片
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, FileCtrl, ActnList, ExtCtrls, ComCtrls;
type
TMain_Form = class(TForm)
Label1: TLabel;
SpdButn_selectsource: TSpeedButton;
SpdButn_selectecausefile: TSpeedButton;
Label2: TLabel;
Label3: TLabel;
Butn_Ok: TButton;
Butn_Exit: TButton;
Edit_SourceFileName: TEdit;
Edit_TargetDircetory: TEdit;
ActionList1: TActionList;
ExitAction: TAction;
Label6: TLabel;
Edit_PartitionFileSize: TEdit;
Label7: TLabel;
GrouPBox_Size: TGroupBox;
RadBtn_Mb: TRadioButton;
RadBtn_Kb: TRadioButton;
procedure SpdButn_selectsourceClick(Sender: TObject);
procedure Butn_ExitClick(Sender: TObject);
procedure SpdButn_selectecausefileClick(Sender: TObject);
procedure Edit_TargetDircetoryMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure ExitActionExecute(Sender: TObject);
procedure Butn_OkClick(Sender: TObject);
procedure Edit_SourceFileNameMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure RadBtn_KbClick(Sender: TObject);
procedure RadBtn_MbClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
sourceF, TargetF: file;
TargetFileDircetory, SourceFileDircetory, TargetFileC, SourceDircetory, SourceDircetorFind: string;
ReadBufSize: integer;
Buf: array[1..10485760] of Char;
WriteResult, ReadResult, TargetDirectorySize, SecondWriteResult: integer;
FileSe, HadWriteSize: longint; {文件长度}
A, B: Boolean;
SearchResult: TSearchRec;
end;
var
Main_Form: TMain_Form;
implementation
{$R *.dfm}
procedure TMain_Form.SpdButn_selectsourceClick(Sender: TObject); //选择源目录
begin
SelectDirectory('请选择要复制的目录', ', SourceDircetory);
Edit_SourceFileName.Text := SourceDircetory;
end;
procedure TMain_Form.Butn_ExitClick(Sender: TObject);
begin
close; //退出程序
end;
procedure TMain_Form.SpdButn_selectecausefileClick(Sender: TObject);
var //选择目标目录
aPath: string;
begin
aPath := ';
if SelectDirectory('选择保存目录:', 'E:\testfile', aPath) then
Edit_TargetDircetory.Text := aPath;
end;
procedure TMain_Form.Edit_SourceFileNameMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Edit_SourceFileName.Hint := Edit_SourceFileName.Text;
end;
procedure TMain_Form.Edit_TargetDircetoryMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Edit_TargetDircetory.Hint := Edit_TargetDircetory.Text; //Edit2的Hint事件
end;
procedure TMain_Form.ExitActionExecute(Sender: TObject);
begin
close; //退出程序
end;
procedure TMain_Form.Butn_OkClick(Sender: TObject); //开始拷贝按钮
var
FileAttrs, I: integer;
begin
A := True;
b := A;
HadWriteSize := 0;
I := (-1);
if DirectoryExists(Edit_SourceFileName.text) = false then
begin
ShowMessage('指定的文件夹不存在请正确的选择文件夹');
Edit_SourceFileName.text := ';
A := false;
Edit_SourceFileName.SetFocus;
end; //end if
if DirectoryExists(Edit_TargetDircetory.text) = false then
begin
ShowMessage('所选的文件夹不存在,请重新选择');
Edit_TargetDircetory.text := ';
B := false;
Edit_TargetDircetory.SetFocus;
end; {end if}
try
StrToInt(Edit_PartitionFileSize.Text);
except
showmessage('你输入的数字不正确,请正确输入!');
B := false;
end;
FileAttrs := faReadOnly faHidden faSysFile faArchive; //确定要复制文件类型
if (A = true) and (B = true) then
begin
SourceDircetory := Edit_SourceFileName.Text;
if RadBtn_Mb.Checked then //确定一下要分割多大的文件
ReadBufSize := (StrToInt(Edit_PartitionFileSize.Text)) * 1048576
else
ReadBufSize := (StrToInt(Edit_PartitionFileSize.Text)) * 1024;
end; {end if} //确定结束
SourceDircetorFind := (SourceDircetory '\*.*');
TargetDirectorySize := Length(Edit_TargetDircetory.Text);
TargetFileDircetory := Edit_TargetDircetory.Text; {确认下目标路径名}
Delete(TargetFileDircetory, TargetDirectorySize, 1);
if (TargetFileDircetory '\') = Edit_TargetDircetory.Text then
begin {begin if}
TargetFileDircetory := (Edit_TargetDircetory.Text);
end {end if}
else
begin
TargetFileDircetory := (Edit_TargetDircetory.Text '\');
end; {end else}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:图象API学习 v0.1
下一篇:ZLib 流的压缩和解压
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash