Autor Beitrag
sPeeD2k5
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Mi 01.03.06 20:36 
Hallöchen erstma an alle ;)

Also zu meinem Problem:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.Button1Click(Sender: TObject);
type ip = record
  ip: string[15];
  end;
var input,output : file of ip;
  temp : ip;

begin
  AssignFile (input,'ips.txt');
  AssignFile (output,'whois.txt');
  reset (input);
  rewrite (output);
    while not eof(input) do
    begin
    seek (input, FilePos(input)+1);
    Read (input, temp);
    Write (output, temp);
    closefile (input);
    closefile (output);
    end;
end;

end.


Er sagt mir ständig, dass er die Datei nicht finden kann (ips.txt), obwohl ich diese im selben Verzeichnis wie die EXE zu liegen habe... komme einfach nicht dahinter warum er die Datei nicht finde...

need help :(

MfG sPeeD

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
Moderiert von user profile iconChristian S.: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mi 01.03.2006 um 22:41
Dahmsi
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 01.03.06 20:39 
Probier mal:
ausblenden Delphi-Quelltext
1:
extractfilepath(paramstr(0))+'ips.txr'					

als Paramter anzugeben.
sPeeD2k5 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Mi 01.03.06 20:42 
Meinst du so?

ausblenden Delphi-Quelltext
1:
AssignFile (input,extractfilepath(paramstr(0))+'ips.txt');					


falls ja dann funktionierts immer noch nicht... :(

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 01.03.06 20:53 
So sollte es gehen:

ausblenden Delphi-Quelltext
1:
AssignFile (input,extractfilepath(Application.ExeName)+'ips.txt');					


Und ebenfalls für die Output-Datei.

_________________
Markus Kinzler.
sPeeD2k5 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Mi 01.03.06 20:58 
Kommt leider nach wie vor die Fehlermeldung, er könne die Datei nicht finden.
Bin zwar nicht so der Delphiprofi aber is hier:
ausblenden Quelltext
1:
Application.ExeName					

nicht irgendwas falsch?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 01.03.06 21:03 
Was soll daran falsch sein? In der Eigenschaft ExeName des Application-Objekts ( deklariert als Singelton in Forms) steht der Name der exe mit dem kompletten Pfad.

_________________
Markus Kinzler.
sPeeD2k5 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Mi 01.03.06 21:08 
Es handelt sich hierbei doch aber um ein TextFile :?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mi 01.03.06 21:12 
Na Sicher, aber der Pfad fehlt !
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 01.03.06 21:16 
user profile iconsPeeD2k5 hat folgendes geschrieben:
Es handelt sich hierbei doch aber um ein TextFile :?


Ist doch egal! Nehmen wir mal an deine Anwendung heisst Test.exe und liegt im Pfad c:\programme\test. Dann liefert Application.ExeName c:\programme\test\Test.Exe. Die Funktion ExtractFilePath enfernt jetzt den Dateinamen und es bleibt der Pfad c:\programme\test\ übrig, an den jetzt ips.txt bzw whois.tct angehängt wird und es dann c:\programme\test\ips.txt bzw c:\programme\test\whois.txt als dateinamen ergibt.

_________________
Markus Kinzler.
sPeeD2k5 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Mi 01.03.06 21:19 
Ok klingt logisch. Allerdings probier mal den quellcode zu compilieren mit deiner Modifizierung... funktioniert nach wie vor nicht *ratlos sei*
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mi 01.03.06 21:23 
Das war doch auch garnicht gefragt, denk Ich mal ob nun extractfilepath(Application.ExeName) oder extractfilepath(paramstr(0)) das kommt aufs selbe raus.
Aber du hast in deinem Code keine ordentliche Pfad Angabe, oder man kann sie eben nicht erkennen (weil noch Code Fehlt!?).
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 01.03.06 21:25 
Laß dir mal das im Programm oder Debugger anzeigen extractfilepath(Application.ExeName)+'ips.txt'

_________________
Markus Kinzler.
sPeeD2k5 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Mi 01.03.06 21:25 
habs doch mit beidem schon probiert.. aber was sol denn da fehlen? pathangabe erfolgt doch sicherlich nur einmal :O
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mi 01.03.06 21:41 
File of Ip - String [15] !?
sPeeD2k5 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Mi 01.03.06 21:44 
bedeutet doch nicht mehr als dass nen string nich mehr als 15 zeichen haben darf :O
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 01.03.06 21:48 
und das sollte für eine IP-Adresse gerade reichen. Hast du dir mal den wert von Application.Exename bzw paramstr(0) anzeigen lassen?

_________________
Markus Kinzler.


Zuletzt bearbeitet von mkinzler am Mi 01.03.06 21:52, insgesamt 1-mal bearbeitet
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mi 01.03.06 21:48 
Problem erkannt !
sPeeD2k5 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Do 02.03.06 19:35 
user profile iconBlackheart666 hat folgendes geschrieben:
Problem erkannt !


ahja? an dem string[15] liegt es doch wohl eher nicht...
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Do 02.03.06 22:38 
Die Dateien ips.txt und whois.txt müssen schon im Ordner der Exe vorhanden sein !

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.Button1Click(Sender: TObject);
type ip = record  
  ip: string[15];  
  end;  
var input,output : file of ip;  
  temp : ip;  


begin
  AssignFile (input,ExtractFilePath(Paramstr(0))+'ips.txt');
  AssignFile (output,ExtractFilePath(Paramstr(0))+'whois.txt');
  reset (input);
  rewrite (output);  
    while not eof(input) do  
    begin  
    seek (input, FilePos(input)+1);  
    Read (input, temp);  
    Write (output, temp);  
    closefile (input);  
    closefile (output);  
    end;  
end;