FolderItem.OpenAsVirtualVolume

From Xojo Documentation

Method

FolderItem.OpenAsVirtualVolume() As VirtualVolume

Supported for all project types and targets.

Attempts to open the FolderItem as a VirtualVolume. It returns Nil if the FolderItem is not a VirtualVolume.

Notes

It is opened as Read/Write unless it is locked at the operating system level.

Example

The following example reads a text file that was saved earlier. It is passed the name of the file.

Sub ReadTextFile(s As String)
// reads the text file in the VirtualVolume
Var f, virtualFile As Folderitem
Var v As VirtualVolume
f = FolderItem.ShowOpenFileDialog("myVirtualVolume")
If f <> Nil Then
v = f.OpenAsVirtualVolume
If v <> Nil Then
virtualFile = v.Root.Child(s)
If VirtualFile <> Nil Then
Var stream As BinaryStream
stream = BinaryStream.Open(virtualFile, False)
Do
TextArea2.AddText(stream.Read(255))
Loop Until stream.EndOfFile
stream.Close
End If
End If
End If
End Sub