彻底删除文件(Delphi源码)
更新时间:2023-10-13 08:49:01 阅读量: 综合文库 文档下载
- delphi 删除文件推荐度:
- 相关推荐
彻底删除文件源码
unit Unit1;
interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls; type
TForm1 = class(TForm) Button1: TButton;
OpenDialog1: TOpenDialog; Button2: TButton; Edit1: TEdit;
ProgressBar1: TProgressBar; Button3: TButton; Button4: TButton; Timer1: TTimer; Button5: TButton;
procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private
{ Private declarations } public
{ Public declarations } end; var
Form1: TForm1; FileName:String;
implementation
{$R *.dfm}
Procedure DelOne(FileName:String); var
f: file of byte; n: byte; i:integer;
SizeInt:Int64; begin
AssignFile(f, FileName); Reset(f);
SizeInt:=FileSize(f); n := 0;
for i := 1 to SizeInt do begin
BlockWrite(f, n, 1); end;
CloseFile(f); end;
Procedure DelTwo(FileName:String); var
f: file of byte; n: byte; i:integer; begin
AssignFile(f, FileName); Reset(f); n := 1;
for i := 1 to FileSize(f) do begin
BlockWrite(f, n, 1); end;
CloseFile(f); end;
Procedure DelThree(FileName:String); var
f: file of byte; n: byte; i:integer; begin
Randomize;
AssignFile(f, FileName); Reset(f);
for i := 1 to FileSize(f) do begin
n :=Random(3); BlockWrite(f, n, 1); end;
CloseFile(f);
end;
Procedure DelFour(FileName:String); var
f: file of byte; n: byte; i:integer; begin
Randomize;
AssignFile(f, FileName); Reset(f);
for i := 1 to FileSize(f) do begin
n :=Random(4); BlockWrite(f, n, 1); end;
CloseFile(f); end;
Procedure Delfive(FileName:String); var
f: file of byte; n: byte; i:integer; begin
Randomize;
AssignFile(f, FileName); Reset(f);
for i := 1 to FileSize(f) do begin
n :=Random(5); BlockWrite(f, n, 1); end;
CloseFile(f); end;
Procedure Delsix(FileName:String); var
f: file of byte; n: byte; i:integer; begin
Randomize;
AssignFile(f, FileName);
Reset(f);
for i := 1 to FileSize(f) do begin
n :=Random(6); BlockWrite(f, n, 1); end;
CloseFile(f); end;
Procedure Delsven(FileName:String); var
f: file of byte; n: byte; i:integer; begin
Randomize;
AssignFile(f, FileName); Reset(f);
for i := 1 to FileSize(f) do begin
n :=Random(7); BlockWrite(f, n, 1); end;
CloseFile(f); end;
Procedure DelEt(FileName:String); var
f: file of byte; n: byte; i:integer; begin
Randomize;
AssignFile(f, FileName); Reset(f);
for i := 1 to FileSize(f) do begin
n :=Random(8); BlockWrite(f, n, 1); end;
CloseFile(f); end;
Procedure DelNine(FileName:String);
var
f: file of byte; n: byte; i:integer; begin
Randomize;
AssignFile(f, FileName); Reset(f);
for i := 1 to FileSize(f) do begin
n :=Random(9); BlockWrite(f, n, 1); end;
CloseFile(f); end;
procedure TForm1.Button1Click(Sender: TObject); begin
DelOne(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelTwo(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelThree(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelFour(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; Delfive(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelSix(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; Delsven(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelEt(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelNine(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DeleteFile(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; ShowMessage('OK'); end;
procedure TForm1.Button2Click(Sender: TObject); begin
if OpenDialog1.Execute then
Edit1.Text:=OpenDialog1.FileName; end;
procedure TForm1.Timer1Timer(Sender: TObject); begin
DelOne(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelTwo(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelThree(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelFour(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; Delfive(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelSix(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; Delsven(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelEt(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DelNine(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; DeleteFile(Edit1.Text);
ProgressBar1.Position:=ProgressBar1.Position+1; ShowMessage('OK'); Timer1.Enabled:=False; end;
procedure TForm1.Button3Click(Sender: TObject); begin
Timer1.Enabled:=True; end;
procedure TForm1.Button4Click(Sender: TObject); begin
Timer1.Enabled:=False; end; end.
正在阅读:
彻底删除文件(Delphi源码)10-13
2014-2015学年湖南省湘西州花垣县大龙小学五年级(上)期04-12
工行牡丹联名卡说明08-22
支部书记年终考核述职述廉报告09-27
安全生产法律法规模拟试题10-19
春雨绵绵九华山散文03-30
最全的运筹学复习题及答案06-21
我的假期小学生作文06-15
英雄纪念碑作文400字06-30
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 源码
- 彻底
- 删除
- 文件
- Delphi