Hallo..
ich habe folgendes problem:das program läuft zwar soweit aber sobald ich dateien ab einer größe von ca 1mb einlese wird das programm nicht mehr zu ende geführt!!brauch des für die schule also bitte helft mir
freu mich über alles was ihr an tipps habt. danke schonmal
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, strutils;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Memo1: TMemo;
Edit1: TEdit;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
NewFileName: string;
Msg: string;
NewFile: TFileStream;
OldFile: TFileStream;
buffer: array[0..100000] of integer;
i: integer;
begin
if opendialog1.Execute then NewFileName := ExtractFilePath(Application.ExeName) + ExtractFileName(opendialog1.FileName)+'.ver';
Msg := Format('Copy %s to %s?', [opendialog1.filename, NewFileName]);
begin
OldFile := TFileStream.Create(opendialog1.filename, fmOpenRead or fmShareDenyWrite);
try
NewFile := TFileStream.Create(NewFileName, fmCreate or fmShareDenyRead);
try
{----------------------------------}
edit1.Text := inttostr(oldfile.Size);
for i := 1 to oldfile.Size do
begin
OldFile.Read(Buffer[i], 1);
memo1.Lines.Add(inttostr(buffer[i]));
end;
for i := 1 to oldfile.Size do
buffer[i] := buffer[i]+5;
for i := 1 to oldfile.Size do
begin
NewFile.Write(Buffer[i], 1);
end;
{----------------------------------}
finally
FreeAndNil(NewFile);
end;
finally
FreeAndNil(OldFile);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
NewFileName: string;
Msg: string;
NewFile: TFileStream;
OldFile: TFileStream;
buffer: array[0..100000] of integer;
i: integer;
begin
if opendialog1.Execute then
begin
NewFileName := ExtractFilePath(Application.ExeName) + ExtractFileName(opendialog1.FileName);
newfilename := leftstr(newfilename, length(newfilename)-4);
end;
Msg := Format('Copy %s to %s?', [opendialog1.filename, NewFileName]);
begin
OldFile := TFileStream.Create(opendialog1.filename, fmOpenRead or fmShareDenyWrite);
try
NewFile := TFileStream.Create(NewFileName, fmCreate or fmShareDenyRead);
try
{----------------------------------}
edit1.Text := inttostr(oldfile.Size);
for i := 1 to oldfile.Size do
begin
OldFile.Read(Buffer[i], 1);
memo1.Lines.Add(inttostr(buffer[i]));
end;
for i := 1 to oldfile.Size do
buffer[i] := buffer[i]-5;
for i := 1 to oldfile.Size do
begin
NewFile.Write(Buffer[i], 1);
end;
{----------------------------------}
finally
FreeAndNil(NewFile);
end;
finally
FreeAndNil(OldFile);
end;
end;
end;
end.