UserGuide

Virtual Volume

From Xojo Documentation

fa-exclamation-circle-32.png
The VirtualVolume class was deprecated in 2019r3.

A Virtual Volume is a special file object that acts as a container for other files. It allows you to have a single file that consists of multiple files. Virtual Volumes are manipulated using the VirtualVolume class along with FolderItems for supporting reading and writing of Text and Binary files. Virtual Volumes can be used to easily create custom file formats that need to contain other files.

Virtual Volumes are not available for iOS projects.

Creating Virtual Volumes

You create a Virtual Volume using the CreateVirtualVolume method of a FolderItem.

Dim vFile As FolderItem
vFile = GetFolderItem(“TestVolume.vv”)
Dim vv As VirtualVolume
vv = vFile.CreateVirtualVolume

CreateVirtualVolume returns Nil if the Virtual Volume could not be created. Once you have a Virtual Volume, you can access or add files to it using FolderItems.

Accessing Data in Virtual Volumes

Extending the previous example, you can add a text file to the Virtual Volume by creating a FolderItem in it and then writing text to it using a TextOutputStream:

If vv <> Nil Then
Dim testFile As FolderItem
testFile = vv.Root.Child("Test.txt")
Dim output As TextOutputStream
output = TextOutputStream.Create(testFile)
output.Write("Hello, world!")
output.Close
End If

See Also

FolderItem, VirtualVolume classes; UserGuide:Framework topic