Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi TStrings AccessViolatino Error (https://www.delphipraxis.net/68811-tstrings-accessviolatino-error.html)

patrickhessman 5. Mai 2006 21:05


TStrings AccessViolatino Error
 
Hallo!

1. Ich habe ein ganz seltsames Problem.
Delphi-Quellcode:
var
  l: TStrings;
begin
  l := TStrings.Create;
    l.LoadFromFile(<irgendwas>);
  l.Free;
end;
beschert mir immer einen AV Error. :coder2:
Wie kommt das? Hab schon ein wenig gestöbert
bin aber auf nichts sinnvolles gestoßen.

2. Geht warscheinlich total schnell :oops: :
Wie erstelle ich eine kopie der datei A
nach B?

Danke im Vorraus!

Patrick H. :dp:

Luckie 5. Mai 2006 21:08

Re: TStrings AccessViolatino Error
 
TStrings ist eine abstrakte Klasse. Nimm eine TStringList.

patrickhessman 5. Mai 2006 21:12

Re: TStrings AccessViolatino Error
 
Vielen Dank!
Super schnelle Antwort. Funktioniert!!!!! =)
Aber was war mein Fehler? Was ist eine Abstrakte Klasse?
Bzw. was is das Problem mit Abstrakten Klassen?
Ich lerne gern dazu =)

Luckie 5. Mai 2006 21:14

Re: TStrings AccessViolatino Error
 
Delphi-Referenz durchsuchenabstract
Zitat:

An abstract method is a virtual or dynamic method that has no implementation in the class where it is declared. Its implementation is deferred to a descendant class. Abstract methods must be declared with the directive abstract after virtual or dynamic. For example,

procedure DoSomething; virtual; abstract;

You can call an abstract method only in a class or instance of a class in which the method has been overridden.

Bernhard Geyer 5. Mai 2006 21:36

Re: TStrings AccessViolatino Error
 
Zitat:

Zitat von patrickhessman
Was ist eine Abstrakte Klasse?

Abstrakte Klasse

nat 5. Mai 2006 22:15

Re: TStrings AccessViolatino Error
 
mach
Delphi-Quellcode:
var
  lst: TStrings;
begin
  lst := TStringList.Create;
  try
    lst.LoadFromFile(filename);
  finally
    lst.free;
  end;
end;
zur 2. frage nimm entweder ne funktion
Zitat:

BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
oder machs mit 2 filestreams (falls du dazwischen evtl. noch rumfummeln mußt)
Delphi-Quellcode:
  fsIn := TFileStream.Create(inputfile, fmOpenRead or fmShareDenyWrite);
  try
    fsOut := TFileStream.Create(outputfile, fmCreate or fmShareDenyWrite);
    try
      fsIn.Position := 0;
      fsOut.CopyFrom(fsIn, fsIn.Size)
    finally
      fsOut.free;
    end;
  finally
    fsIn.free;
  end;
statt copyfrom könntest du auch blockweise lesen/schreiben und so z.B.
n statusbalken noch anzeigen lassen.

patrickhessman 6. Mai 2006 09:55

Re: TStrings AccessViolatino Error
 
Ok dann is jetzt alles klar! danke!


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:47 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz