只要能运行就给分

解决方案 »

  1.   

    来自Delphi帮助This example copies a specified file into the same directory as the application.procedure TForm1.Save1Click(Sender: TObject);var
      NewFileName: string;
      Msg: string;
      NewFile: TFileStream;
      OldFile: TFileStream;
    begin
      NewFileName := ExtractFilePath(Application.ExeName) + ExtractFileName(Edit1.Text);
      Msg := Format('Copy %s to %s?', [Edit1.Text, NewFileName]);
      if MessageDlg(Msg, mtConfirmation, mbOKCancel, 0) = mrOK then
      begin
        OldFile := TFileStream.Create(Edit1.Text, fmOpenRead or fmShareDenyWrite);
        try
          NewFile := TFileStream.Create(NewFileName, fmCreate or fmShareDenyRead);      try
            NewFile.CopyFrom(OldFile, OldFile.Size);
          finally
            FreeAndNil(NewFile);
          end;
        finally
          FreeAndNil(OldFile);
        end;
      end;end;