最近采了一组数据,但发现第一个数据后面多了个点,故想用Delphi编个小程序批量处理一下,数据为'.DAT'格式,

。
编程如下:

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
Button2: TButton;
Button1: TButton;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
WFile,RFile:TextFile;
WF,RF,P:String;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
WF:= OpenDialog1.FileName;
RF:= Copy(OpenDialog1.FileName,4,length(OpenDialog1.FileName)-8)+'.DAT';
Button3.Enabled:=true;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
AssignFile(WFile,WF);
Reset(WFile);
AssignFile(RFile,RF);
Rewrite(RFile);
While not EOF(WFile) do
begin
ReadLn(WFile,P);
Delete(P,13,1);
WriteLn(RFile,P);
end;
CloseFile(WFile);
CloseFile(RFile);
ShowMessage('Done');
end;
end.
但运行时提示exception class EInOutError with message 'Invalid FileName'错误,

查看网上各种资料也没解决,想在这里请教一下。有人同样遇到这种问题么?