secantau
2002-06-06 02:52:31 UTC
I'm having trouble reading from a FileStream. I've searched the
delphi help and the list archive and can't seem to find much help.
I want to read the first 15 characters from a text file but I keep
getting a blank string (which it shouldn't be).
What's wrong with this code ?
var
MyFile : TFileStream;
sMsg: String;
PtrData : Pchar;
begin
If FileExists('C:\Mitmr.txt') then
begin
MyFile := TFileStream.Create('C:\Mitmr.txt',fmOpenRead or
fmShareDenyWrite);
MyFile.Seek(0, soFromBeginning);
MyFile.Read(PtrData^,15);
sMsg := string(PtrData);
showMessage(sMsg);
end;
end;
delphi help and the list archive and can't seem to find much help.
I want to read the first 15 characters from a text file but I keep
getting a blank string (which it shouldn't be).
What's wrong with this code ?
var
MyFile : TFileStream;
sMsg: String;
PtrData : Pchar;
begin
If FileExists('C:\Mitmr.txt') then
begin
MyFile := TFileStream.Create('C:\Mitmr.txt',fmOpenRead or
fmShareDenyWrite);
MyFile.Seek(0, soFromBeginning);
MyFile.Read(PtrData^,15);
sMsg := string(PtrData);
showMessage(sMsg);
end;
end;