Autor Beitrag
MarkusBauer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 70

Win XP Pro
Delphi 7 PE+Indy
BeitragVerfasst: Fr 27.10.06 10:20 
Hallo,
ich möchte eine Datei laden, die jedoch fortlaufend aktualisiert wird.
Die Datei wird über das MS-Dos-Kommando lame.exe "Test.wav" "Test.mp3" > Test.txt 2>&1 in eine Textdatei Test.txt geschrieben. Soll die Datei nun geladen werden (Memo1.Lines.Loadfromfile('Test.txt')), während lame.exe mit seiner Arbeit noch nicht fertig ist, erscheint die Fehlermeldung "Die Datei Test.txt kann nicht geöffnet werden. ". Mit einem anderen Texteditor wie Notepad klappt dies problemlos. Wie kann ich die Datei trotzdem öffnen???
Matthias-K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271

Win95, Win98, Win2000, WinXP, Linux
D2, D4 Client/Server, D5 Enterprise, D6 Enterprise, D7 Enterprise, Delphi2005, C/C++ 3.0, C/C ++ 5.0, C/C++ 6.0
BeitragVerfasst: Fr 27.10.06 10:28 
dunkel erinnere ich mich daran, das man eine datei auch als "nur lesen" öffnen kann!

das müsste das problem beheben.

_________________
Ein Spezialist ist ein Mensch, der immer mehr von immer weniger weis, bis er alles von nichts weis!
Danny W.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Fr 27.10.06 10:42 
Magst du evtl. mal sagen wie das funktioniert? das würde mich auch interessieren :)


mfG
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 27.10.06 10:50 
Mit der Methode LoadFromFile geht es nicht, aber du kannst sie in ein Stream laden und dann mit der Methode LoadFromStream im Memo anzeigen lassen.
MarkusBauer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 70

Win XP Pro
Delphi 7 PE+Indy
BeitragVerfasst: Sa 28.10.06 15:41 
Das mit dem Stream funktioniert leider auch nicht. Jetzt wird der Fehler gemeldet, wenn ich die Datei mit TMemorystream.Loadfromfile laden möchte. Was ist falsch?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 28.10.06 16:46 
Wie lädst du sie mit dem Stream?
MarkusBauer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 70

Win XP Pro
Delphi 7 PE+Indy
BeitragVerfasst: Sa 28.10.06 18:27 
Ich lade die Datei so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var stream: TMemorystream;

Stream := TMemorystream.Create;
Stream.Loadfromfile('Test.txt');   //Hier wird die Fehlermeldung ausgegeben!
Memo1.LoadfromStream(Stream);
Stream.Free;
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Sa 28.10.06 18:36 
Hallo,

Luckie hat doch gesagt, dass es mit LoadFromFile nicht geht.
Versuchs mal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  Stream: TFileStream;
begin
  Stream := TFileStream.Create(AFileName, fmOpenRead or fmShareDenyNone);
  try
    Memo1.Lines.LoadFromStream(Stream);
  finally
    Stream.Free;
  end;
end;
Gruß Hape!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Sa 28.10.06 18:37 
Den Pfad deiner Textdatei musst du natürlich auch noch angeben!
Liegt sie im selben verzeichnis wie deine Exe, so kannst du folgendes schreiben:
Stream.Loadfromfile(extractfilepath(paramstr(0))+'Text.txt'); ;)
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Sa 28.10.06 18:51 
@Marc: Der steckt bei Wulskin in der Variable AFileName drinnen ;)

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
MarkusBauer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 70

Win XP Pro
Delphi 7 PE+Indy
BeitragVerfasst: Sa 28.10.06 18:55 
Danke, jetzt funktionierts endlich!
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Sa 28.10.06 19:50 
user profile iconalias5000 hat folgendes geschrieben:
@Marc: Der steckt bei Wulskin in der Variable AFileName drinnen ;)

Gruß alias5000

mein beitrag bezog sich auch nicht auf wulfskins post, sondern auf den davor;)

welche lösung hat dir denn nun geholfen?
MarkusBauer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 70

Win XP Pro
Delphi 7 PE+Indy
BeitragVerfasst: Sa 28.10.06 20:17 
Endgültig funktioniert jetzt der Quellcode von Wulfskin, nach der Eingabe der Textdatei lief alles wunderbar. :lol: