Platforms to show: All Mac Windows Linux Cross-Platform

FolderItem.ReadFileMBS(byref data as MemoryBlock) as boolean
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Util Plugin 21.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Reads a file to a memory block.
Example:
Dim f As New FolderItem("/Users/cs/Downloads/Download Archive/Xcode_13_beta_5.xip", FolderItem.PathModes.Native)

Dim m As MemoryBlock
'Dim m As New MemoryBlock(f.Length)

If f.ReadFileMBS(m) Then
// okay
Dim Len As Integer = m.size
Break
Else
// failed
Dim e As Integer = f.LastErrorCode
Break
End If
Notes:
Reads content of file and returns it in data parameter.
Returns true on success of false on failure.

See also WriteFileMBS function.

If the MemoryBlock is nil, we create one.
If the MemoryBlock is not nil and has right size, we use it, otherwise we create a new one.
Not intended for files >2 GB.

See also:

Some examples using this method:

Feedback, Comments & Corrections

FolderItem.ReadFileMBS(byref data as string) as boolean
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Util Plugin 19.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Reads a file.
Notes:
Reads content of file and returns it in data parameter.
Returns true on success of false on failure.

See also WriteFileMBS function.

Limited to maximum size of a string (2 GB)
Data must fit in memory, so 32-bit processes may be limited to reading less than 2 GB.

See also:

Some examples using this method:

Blog Entries

Xojo Developer Magazine

Videos

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.

The biggest plugin in space...




Links
MBS Xojo Plugins

Start Chat