Platforms to show: All Mac Windows Linux Cross-Platform
Back to FolderItem class.
FolderItem.ReadFileMBS(byref data as MemoryBlock, offset As Integer = 0, byteCount As Integer = -1) as boolean
Function:
Reads a file to a memory block.
Example:
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.
Added offset and length parameters in version 23.1.
If byteCount is negative, we read whole file. If byteCount is bigger than file, we only read the available portion.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Files | MBS Util Plugin | 21.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
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
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.
Added offset and length parameters in version 23.1.
If byteCount is negative, we read whole file. If byteCount is bigger than file, we only read the available portion.
See also:
Some examples using this method:
FolderItem.ReadFileMBS(byref data as string, offset As Integer = 0, byteCount As Integer = -1) as boolean
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.
Added offset and length parameters in version 23.1.
If byteCount is negative, we read whole file. If byteCount is bigger than file, we only read the available portion.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Files | MBS Util Plugin | 19.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
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.
Added offset and length parameters in version 23.1.
If byteCount is negative, we read whole file. If byteCount is bigger than file, we only read the available portion.
See also:
Some examples using this method:
Blog Entries
- MBS Xojo Plugins, version 23.1pr6
- News from the MBS Xojo Plugins Version 21.4
- MBS Xojo Plugins, version 21.4pr5
- MBS Xojo Plugins in version 19.0
- MBS Xojo Plugins, version 18.6pr1
Xojo Developer Magazine
- 21.1, page 28
- 17.5, page 40: What's New in the MBS Plugins, With the Plugins growing every year, here are new capabilities you may have missed by Stefanie Juchmes
- 17.2, page 10: News
Videos
The items on this page are in the following plugins: MBS Util Plugin.
