Autor Beitrag
Peter_Lustig
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 31



BeitragVerfasst: Di 04.10.05 11:48 
Hallo erstmal, hab da folgendes Problem,
ich will das wenn ich auf eine Button klicke, das eine angegebene Datei in das ausgewählte verzeichnis kopiert wir, aber die Datei ist dann nicht in den angegebenen Ordner, aber wenn ich es mit einen im Programm festgelegten Ordner machen klappts.
Hab ihr mal eine auszug aus dem Code, vielleicht könnt ihr mir sagen wo`s klemmt.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.DriveComboBox1Change(Sender: TObject);
begin
DirectoryListBox1.Drive := DriveComboBox1.Drive;

end;

procedure TForm1.Button1Click(Sender: TObject);
var
name,
pfad    :string;
begin
  name := Edit1.Text;
  pfad := DirectoryListBox1.Directory;
  CopyFile('tux.exe', PChar(pfad + name), false);

end;


Moderiert von user profile iconKlabautermann: Code- durch Delphi-Tags ersetzt
Moderiert von user profile iconChristian S.: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Di 04.10.2005 um 12:55
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Di 04.10.05 11:50 
Ich schätze mal, das zwischen (pfad + name) ein Backslash fehlt: (pfad + '\' + name)

Alstar
Peter_Lustig Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 31



BeitragVerfasst: Di 04.10.05 11:54 
Hab ich so gemacht, kling ja auch logisch, aber klappt trotzdem nicht.
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Di 04.10.05 11:56 
Bist Du sicher, dass sich die "Tux.exe" im aktuellen Verzeichnis befindet? (Das ist nicht immer das VErzeichnis in dem die EXE liegt!)
Probier einfach, dort mal das Verzeichnis mit anzugeben

Alstar
Peter_Lustig Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 31



BeitragVerfasst: Di 04.10.05 12:06 
Ja, die beiden *.exe Datein liegen in einem Verzeichnis, es klappt ja, wenn ich anstatt
CopyFile('tux.exe', PChar(pfad + '\' + name) , false); zu beispiel CopyFile('tux.exe', Tax\tax.exe) , false); eingebe.
Flocke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54

Win 2000, Win XP, Win 2003, Linux
Delphi 2006 Prof.
BeitragVerfasst: Di 04.10.05 12:24 
1. Hast du in der DriveComboBox ggf. das Laufwerk gewechselt?
2. Probiere mal:
ausblenden Delphi-Quelltext
1:
CopyFile(PChar(ExtractFilePath(Application.ExeName) + 'tux.exe'), PChar(pfad + '\' + name) , false);					
Peter_Lustig Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 31



BeitragVerfasst: Di 04.10.05 12:41 
hy danke, mit deim Code hats geklappt, was ist da jetzt genau der Unterschied zum meinem Code? :?:
Flocke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54

Win 2000, Win XP, Win 2003, Linux
Delphi 2006 Prof.
BeitragVerfasst: Di 04.10.05 12:48 
Ich habe einfach das Verzeichnis hinzugefügt, so wie Alstar es dir vorgeschlagen hat:
user profile iconAlstar hat folgendes geschrieben:
Bist Du sicher, dass sich die "Tux.exe" im aktuellen Verzeichnis befindet? (Das ist nicht immer das VErzeichnis in dem die EXE liegt!)
Probier einfach, dort mal das Verzeichnis mit anzugeben


Das aktuelle Verzeichnis ist nicht das, in dem sich dein Programm befindet (diese Annahme ist selbst beim Programmstart oft nicht gegeben).

Application.ExeName ist der vollständige Pfad deiner Anwendung - ExtractFilePath() holt sich den Pfad daraus.
Peter_Lustig Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 31



BeitragVerfasst: Di 04.10.05 13:07 
Cool danke!!!
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Do 20.10.05 16:03 
Hab da leider auch ein Problem zu...

ausblenden Delphi-Quelltext
1:
CopyFile(PChar(urpfad), PChar(lokpfad), false);					


Das funktioniert bei mir nicht. Beide Pfade sind in den Variablen absolut deklariert, und sind auch richtig (werden in ne .ini gespeichert bzw. daraus gelesen). Der Ordner im lokpfad, der eventuell nicht existiert, wird vorher durch ForceDirectories erzeugt (klappt auch). Nur die Datei wird nicht kopiert. Warum???

//Edit
Hat sich erledigt... :oops: *sich mitm hämmerchen aufn schädel haut*
die Datei die ich kopieren wollte, hatte ne andere Endung als wie se im Pfad stand :angel: