GARANTIR DESCONTO

Fórum erro no CopyFile #290242

01/08/2005

0

Estou tentando fazer uma aplicação para atualizar um arquivo em varias pastas diferentes. Atualmente preciso copiar e colar o arquivo em cada uma das pastas, e sobrepor o arquivo destino, renomeando-o se necessario. Aqui está o codigo:

unit Uatl;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, shellapi;
const
  local1: string = ´x:´;
  local2: string = ´Y:\SIGS´;
  local3: string = ´Y:\SIGS_CT01´;
  local4: string = ´Y:\SIGS_CT02´;
  local5: string = ´Y:\SIGS_CT03´;
  local6: string = ´Y:\SIGS_CT04´;
  local7: string = ´Y:\SIGS_BLM´;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    OpenDialog1: TOpenDialog;
    Button1: TButton;
    Memo1: TMemo;
    Label2: TLabel;
    Label3: TLabel;
    SpeedButton2: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    function ExtractName(const Filename: String): String;

  end;

var
  Form1: TForm1;
  sext,cext,dest: string;
  i: integer;

implementation

uses Uajuda;

{$R *.dfm}

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  if opendialog1.Execute=true then
     begin
       cext:=opendialog1.FileName;
       label2.Caption:=cext;
       sext:=extractname(opendialog1.FileName);
       dest:=´d:/´+sext+´.exe´;
     end;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
  frmajuda.showmodal;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    renamefile (cext,´d:/´+sext+´.xyz´);
    if fileexists (´d:/´+sext+´.xyz´) then
      memo1.Lines.add(´Renomeado´);
    copyfile(cext,dest);

end;

function tform1.ExtractName(const Filename: String): String;
{Retorna o nome do Arquivo sem extensão}
var
  aExt : String;
  aPos : Integer;
begin
  aExt := ExtractFileExt(Filename);
  Result := ExtractFileName(Filename);
  if aExt <> ´´ then
    begin
      aPos := Pos(aExt,Result);
    if aPos > 0 then
      begin
        Delete(Result,aPos,Length(aExt));
      end;
  end;
end;
end.


Ocorre um erro na linha: copyfile(cext,dest); Tipo incompatível String e PansiChar.

Quando utilizo: copyfile(pchar(cext),pchar(dest)); O erro é ´not possible with actual parameters.´

Alguem pode me ajudar?


Fernando Lempê

Fernando Lempê

Responder

Posts

03/08/2005

Fernando Lempê

alguem pode ajudar?


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar