Click or drag to resize

IFileTransferDataAsync Method

IT Hit User File System
Transfers data from remote sorage to user file system.

Namespace:  ITHit.FileSystem
Assembly:  ITHit.FileSystem (in ITHit.FileSystem.dll) Version: 1.4.4298.0
Syntax
Task TransferDataAsync(
	long offset,
	long length,
	ITransferDataOperationContext operationContext,
	ITransferDataResultContext resultContext
)

Parameters

offset
Type: SystemInt64
File content offset, in bytes, to start reading from.
length
Type: SystemInt64
Data length to read, in bytes.
operationContext
Type: ITHit.FileSystemITransferDataOperationContext
Provides additional parameters for this operation and information about the environment.
resultContext
Type: ITHit.FileSystemITransferDataResultContext
Context for returning data to the platform and reporting operation progress and status.

Return Value

Type: Task
.
Remarks

Called, when the file content should be transfetred from the remote torage to user file system. For example when the file should be hydrated.

To returned the transferred data to the operating system, call the ReturnData(Byte, Int64, Int64) method of the ITransferDataResultContext interface, passed via resultContext parameter.

Examples

The code below is part of 'VirtualFileSystem' C# sample provided with the SDK.

C#
public async Task TransferDataAsync(long offset, long length, ITransferDataOperationContext operationContext, ITransferDataResultContext resultContext)
{
    // This method has a 60 sec timeout. 
    // To process longer requests and reset the timout timer call resultContext.ReportProgress() method.

    Logger.LogMessage($"IFile.TransferDataAsync({offset}, {length})", UserFileSystemPath);

    SimulateNetworkDelay(length, resultContext);

    long optionalLength = length + operationContext.OptionalLength;

    byte[] buffer = await new UserFile(UserFileSystemPath).ReadAsync(offset, optionalLength);

    resultContext.ReturnData(buffer, offset, optionalLength);
}
See Also