> {quote:title=Michael Rabatscher wrote:}{quote} > Hi, > > > function TDLHI_Main.ImportKompendium(var MsgList: TListBox; var PrgrssBar: TProgressBar; FileName : string): string; > > var > > i : integer; > > begin > > Result := ''; > > fs := TFileStream.Create(FileName, fmOpenRead + fmShareDenyWrite); > > strstrm := TStringStream.Create(''); > > strstrm.CopyFrom(fs, fs.Size); > > fs.Free; > > i := pos ('<OK_ERROR>', strstrm.DataString); *// ==> And on the this line, I get the out-of-memory-exception!* > > > > It's interesting, to get the exception on the "pos"-Statement and not as I expected on the copying of the stream. > > In Delphi 2007 you get no exception because there you only reference the > string whereas in the unicode version (delphi 2009 and up) the things > got complicated and they had to copy the string using the > right encoding (I guess due to the byte oriented streaming mechanisms > and unicode characters) thus it may happen that you need double the > memory than before! And since many larger continous portions of memory > are not available that often it will cause the out of memory exception > > kind regards > Mike > > > > > In D2007, it worked well; in D2009 I get this error on the mentioned Windows-platforms (I didn't try to run it on other windows-versions) > > > > Thx for all hints. > > Samuel
Hello Mike Thank you for the hint, I was not aware of the DBCS-encoding. I'll try another approach.