Board index » delphi » why filecopy(string,'test.txt',err) doesn't work

why filecopy(string,'test.txt',err) doesn't work

i cant put a string into a filecopy
exemple

var test:string;
     err:booloean;

begin
 test:='test.txt';
 filecopy(test,'test2.txt',err);      {this doesn't work}
 filecopy('test.txt','test2.txt',err);{this works}
end;

is it a bug or am i too blond ?

 

Re:why filecopy(string,'test.txt',err) doesn't work


Quote
Rene A wrote in message <354AF90C.DE486...@worldcity.nl>...
>i cant put a string into a filecopy
>exemple

>var test:string;
>     err:booloean;

>begin
> test:='test.txt';
> filecopy(test,'test2.txt',err);      {this doesn't work}
> filecopy('test.txt','test2.txt',err);{this works}
>end;

>is it a bug or am i too blond ?

Try
var
    Test :  array[0..10] of Char;
    err : Boolean;

Begin
    FillChar(Test, 11, #0);
    StrCopy(Test, 'Test.txt');
   CopyFile(@test,'test2.txt',err);
end;

or in D3

var
    Test :  String;
    err : Boolean;
Begin
    Test :=  'Test.txt';
   CopyFile(PChar(test),'test2.txt',err);
end;

        -- Kirk

Other Threads