Method protected override FileNode CreateFile(DirectoryNode parent, FileNode child)
should create empty file.
I think that this method is not suitable for your scenario.
I am assuming from other information you have provided (http://forum.rebex.net/8351/possibility-to-catch-the-beggining-of-file-transfer) that you are now using LocalFileSystemProvider (https://www.rebex.net/file-server/features/virtual-file-systems.aspx#local-provider) or other virtual file system provider).
Please be aware that for the SFTP server you should have full-fledged file system (built-in LocalFileSystemProvider/MemoryFileSystemProvider or custom file system provider for the remote server or custom file system provider that combines characteristics of the local and remote file system behavior).
All file system providers publish events/hooks:
//Get notifier
FileSystemNotifier notifier = localFS.GetFileSystemNotifier();
//GetFileSystemNotifier() is extension method
//You can replace implementation of the GetContent method.
notifier.GetContentSurrogate += (sender, args) =>
{
//analyze args.Node, args.ContentParameters and decide how to handle request
if (args.Node.IsFile && openForWriteRequest(args))
{
var streamForWrite = new MemoryStream(); //or open your custom special server stream
//Create the delayed write content. Delayed = I will save new content of the file later - when the upload of the file finished.
args.ResultContent = NodeContent.CreateDelayedWriteContent(streamForWrite);
}
};
//You can replace implementation of the SaveContent method.
notifier.SetContentSurrogate += (sender, args) =>
{
//Decide what to do with stream
if (needsSaveOnRemoteServer(args))
{
var fileStream = args.Content.GetStream();
//apply your logic - save the fileStream on the server
//We are done, do not call SaveContent method on the local file system provider.
args.MarkAsHandled();
}
}