Copyfile - Incompatible types: 'String' and 'PAnsiChar' [DELPHI]

0

Jak coś takiego napisać ?

CopyFile('D:\LFS-CARS\'+(samochody.Items.Strings[samochody.ItemIndex])+'\DDS\audi_fm.dds', 'D:\LFSfake\Data\dds\audi_fm.dds', False);
0

http://bit.ly/IS2MAQ

nie szybciej było wpisać w google to samo co wpisałeś w tytule?

0
CopyFile(PAnsiChar('D:\LFS-CARS\'+(samochody.Items.Strings[samochody.ItemIndex])+'\DDS\audi_fm.dds'), 'D:\LFSfake\Data\dds\audi_fm.dds', False);
0

Byłem blisko, pisałem Pchar(....)

0

Podpowiedzcie jeszcze dlaczego ten kod:

 while listbox1.Items.count > 0 do
CopyFile(PAnsiChar('D:\LFS-CARS\'+(samochody.Items.Strings[samochody.ItemIndex])+'\DDS\'+ listbox1.Items.Strings[0]), (PAnsiChar('D:\LFSfake\Data\dds\' + listbox1.Items.Strings[0])), False);
listbox1.Items.Delete(0);

nie kopiuje tego co chce, nie usuwa linii z listbox'a i zawiesza cały program ?

0

Jakbyś go porządnie sformatował to byś wiedział.

while listbox1.Items.count > 0 do
   CopyFile(PAnsiChar('D:\LFS-CARS\'+(samochody.Items.Strings[samochody.ItemIndex])+'\DDS\'+ listbox1.Items.Strings[0]), (PAnsiChar('D:\LFSfake\Data\dds\' + listbox1.Items.Strings[0])), False);

listbox1.Items.Delete(0);

To czego szukasz to:

while listbox1.Items.count > 0 do
begin
  CopyFile(PAnsiChar('D:\LFS-CARS\'+(samochody.Items.Strings[samochody.ItemIndex])+'\DDS\'+ listbox1.Items.Strings[0]), (PAnsiChar('D:\LFSfake\Data\dds\' + listbox1.Items.Strings[0])), False);
  listbox1.Items.Delete(0);
end;

I do jasnej anielki zacznij normalnie nazywać komponenty...

0

Przecież twoja pętla jest nieskończona, bo jest w niej tylko pierwsza linijka.
Pisząc w ten sposób kod szybko się pogubisz.

var srcFile, dstFile:string;

while listbox1.Items.Count > 0 do
begin
  srcFile := 'D:\LFS-CARS\' + samochody.Items.Strings[samochody.ItemIndex] + '\DDS\'+ listbox1.Items.Strings[0];
  dstFile := 'D:\LFSfake\Data\dds\' + listbox1.Items.Strings[0];
  CopyFile(PChar(srcFile), PChar(dstFile), False);
  listbox1.Items.Delete(0);
end;

1 użytkowników online, w tym zalogowanych: 0, gości: 1