The file stream class can be used to buffer large strings incrementally to file. This is one way to allow creating strings that are bigger than 16mb in size.
loFS = CREATEOBJECT("wwFileStream")
loFS.Write("Hello ")
loFs.WriteLine("Rick")
*** Large File
loFS.WriteFile("C:\installs\Distribution CD\Demos\wconnect.exe")
lnSize = loFs.nLength
lcText = loFs.ToString()
lcFile = loFs.cFilename && GUID.txt
this.MessageOut("Size: " + TRANSFORM(loFs.nLength))
this.AssertTrue( lnSize = LEN(lcText) )
loFs.Clear()
this.AssertTrue( loFs.nLength = 0 )
loFS.Dispose()
this.AssertTrue( !FILE(lcFile) )
wwFileStream
Remarks
FoxPro supports access to strings >16mb in a limited fashion. As long as strings are not mutated/changed and are assigned only directly with a single FoxPro operation (like
FILETOSTR()
orloFs.ToString()
) larger than 16mb strings can be used in FoxPro code.
Class Members
Member | Description | |
---|---|---|
Clear |
Clears the stream's buffer and leaves an empty buffer. o.Clear() |
|
Dispose |
Clears the stream and deletes the underlying file that buffers the string data. o.Dispose() |
|
ToBlob |
Returns the content of the file stream as a blob object. o.ToBlob() |
|
ToString |
Returns the content of the stream as a string. Note that this string can potentially be bigger than 16mb in size if stored to a FoxPro variable which works. o.ToString() |
|
Write |
Writes a string to the stream buffer. o.Write(lcContent) |
|
WriteFile |
Writes a file from disk into the memory stream. The file can be a text file or binary file. o.WriteFile(lcFilename) |
|
WriteLine |
Like the Write() method but appends a CRLF to the end of the line.o.WriteLine(lcContent) |
|
nLength |
The current size of the string data stored in the stream. |
© West Wind Technologies, 1996-2024 • Updated: 03/01/19
Comment or report problem with topic