Questions tagged [tfilestream]
40 questions
18
votes
4 answers
How to flush a TFileStream?
TFileStream provides buffered output, which is great in most cases, but in some cases (especially during debugging) it's nice to flush the buffer immediately. Thing is, I don't know of any way to do that except calling Free, which is kind of…

Mason Wheeler
- 82,511
- 50
- 270
- 477
8
votes
2 answers
TFileStream with offset
I need to extend TFileStream so that it can work with a file not from 0 offset, but from user defined offset. I mean it must interpret user defined offset as stream beginning. My code is:
type
TSuFileStream = class(TFileStream)
protected
…

JuniorD
- 83
- 3
6
votes
3 answers
Stream read line
I have a stream reader line by line (sr.ReadLine()). My code counts the line-end with both line endings \r\n and/or \n.
StreamReader sr = new System.IO.StreamReader(sPath, enc);
while (!sr.EndOfStream)
{
//…

procma
- 1,174
- 3
- 14
- 24
6
votes
2 answers
TDownloadURL cannot download from HTTPS
I've been trying to create (TFileStream) a PDF through the TDownloadURL class, but I'm really having troubles in obtaining the file/stream from the URL, specially if the URL a HTTPS.
I'm not sure if I was clear, but I will post a snippet so it might…

Armando Freire
- 417
- 2
- 7
- 19
6
votes
2 answers
writing/reading bitmaps to a tfilestream
i've searched and searched and can't seem to find anything that describes what i'm look to do in delphi code. the solutins are sometimes close but not close enough for me to figure out. so here i am asking..
i have many bitmaps that i am retreaving…

johnm2
- 143
- 3
- 8
6
votes
4 answers
(Wide)String - storing in TFileStream, Delphi 7. What is the fastest way?
I'm using Delphi7 (non-unicode VCL), I need to store lots of WideStrings inside a TFileStream. I can't use TStringStream as the (wide)strings are mixed with binary data, the format is projected to speed up loading and writing the data ... However I…

migajek
- 8,524
- 15
- 77
- 116
4
votes
1 answer
Delphi HTTP App raising error when loading files into streams
I've been working on an HTTP Web Server Application (via TIdHTTPWebBrokerBridge) and have a little issue when it comes to loading files into streams (TFileStream) to be sent back to the client. It doesn't happen every time, but quite randomly... I…

Jerry Dodge
- 26,858
- 31
- 155
- 327
4
votes
2 answers
Appropriate way to cancel saving file via file stream?
A tool I'm writing is responsible for downloading thousands of image files over a matter of many hours. Originally, using TIdHTTP, I would Get the file(s) into a TMemoryStream, and then save that to a file, so long as there were no exceptions. In…

Jerry Dodge
- 26,858
- 31
- 155
- 327
4
votes
6 answers
How to handle exceptions when creating FileStream
I have a function like this, that I would like to refactor
function Myfunction(sUrl, sFile: String) : Boolean;
var
GetData : TFileStream;
begin
Result := False;
//if the line below fails, I get an unhandled exception
…

Sigurdur
- 417
- 4
- 10
4
votes
5 answers
How can I descend from both TFileStream and TMemoryStream?
I have a class that inherits from TFileStream and a class that inherits from TMemoryStream. Both implement exactly the same functions to do with reading data eg:
TCustomFileStream = class (TFileStream)
function ReadByte: byte;
function ReadWord:…

Bennyboy
- 75
- 3
4
votes
2 answers
tfilestream.seek and offset confusion
this is a code snippet taken from https://forums.embarcadero.com/message.jspa?messageID=219481
if FileExists(dstFile) then
begin
Fs := TFileStream.Create(dstFile, fmOpenReadWrite);
try
Fs.Seek(Max(0, Fs.Size-1024), soFromBeginning);
//…

Omair Iqbal
- 1,820
- 1
- 28
- 41
3
votes
1 answer
Isn't the size of Delphi TFileStream WriteBuffer Int64? I'm only able to write small amounts at a time
I'm trying to write larger chunks to increase the speed of the file save. I have about 9 of these loops to convert but I can't figure out what I'm doing wrong
fs := TFileStream.Create(Myfile, fmCreate);
This code works:
for RecordGroup := 0 to…

AWEInCA
- 37
- 7
3
votes
3 answers
What is the fastest way for reading huge files in Delphi?
My program needs to read chunks from a huge binary file with random access. I have got a list of offsets and lengths which may have several thousand entries. The user selects an entry and the program seeks to the offset and reads length bytes.
The…

dummzeuch
- 10,975
- 4
- 51
- 158
3
votes
1 answer
How to use TFileStream with FILE_SHARE_DELETE?
This QC report say that Delphi doesn't support the file sharing mode FILE_SHARE_DELETE
http://qc.embarcadero.com/wc/qcmain.aspx?d=45628
I need to use this mode with TFileStreams - Can anyone think of a straightforward workaround that doesn't involve…

Roddy
- 66,617
- 42
- 165
- 277
3
votes
3 answers
Read Line with TFileStream delphi
How do I read file using certain lines TFileStream. I read lines which has millions of files. So I want to play in memory that I will only use
Example:
Line 1: 00 00 00 00 00 00 00 00
Line 2: 00 00 00 00 00 00 00 00
Line 3: 00 00 00 00 00 00 00…

André
- 93
- 1
- 1
- 9