Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

ReadWriteFileSystemProvider.GetContent Method

Namespace: Rebex.IO.FileSystem
Assembly: Rebex.FileSystem.dll (version 7.0.9147)

GetContent(NodeBase, NodeContentParameters)

Override this method to implement retrieval of the content for the node.

By default, this method is only called for files (instances of the class FileNode). To enable this method for directories (instances of DirectoryNode), add a new instance of FileSystemProviderSettings (with the property EnableGetContentMethodForDirectories set to true) to the ReadOnlyFileSystemProvider(FileSystemProviderSettings) constructor.

When the virtual file system is used in the FileServer component, the server session, which contains information about the user and the active connection, can be accessed using Current property.

Inherited from ReadOnlyFileSystemProvider.
Declaration
protected abstract NodeContent GetContent(NodeBase node, NodeContentParameters contentParameters)
Parameters
Type Name Description
NodeBase node

Processed node.

NodeContentParameters contentParameters

Required properties of the returned NodeContent.

Returns
Type Description
NodeContent

Content for the node.

Examples
protected override NodeContent GetContent(NodeBase node, NodeContentParams contentRequest)
{
 var fullPath = getFullPath(node.Path);
 if (contentRequest.AccesType == NodeContentAccess.Read)
 {
   var readOnlyStream = File.OpenRead(fullPath);
   return NodeContent.CreateReadOnlyContent(readOnlyStream);
 }

 var realFsAccessMode = contentRequest.AccesType == NodeContentAccess.Write
   ? FileAccess.Write
   : FileAccess.ReadWrite;

 var readWriteStream = File.Open(fullPath, FileMode.Open, realFsAccessMode);
 return NodeContent.CreateImmediateWriteContent(readWriteStream);
}
In This Article
  • GetContent(NodeBase, NodeContentParameters)
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies