Closed felipeatsix closed 2 years ago
The name of the method may have been misleading. I've not implemented the ability to move files to another server.
The first argument of the Move method is a relative path, like: "... \anotherFolder\file.txt"
To move a file to another server, use the Read method to get the MemoryStream, Write on the folder node of the other server, and Delete the original node.
Thank you very much for the quick reply, I'm going to try it once I have some time to get back to it, as soon as I can confirm I can do the needful I'll be back to close this.
This worked! thank you
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
if (stoppingToken.IsCancellationRequested)
{
return;
}
var source = await Node.GetNode(@"<ip>\src", "<user>", "<password>");
var sourceFiles = await source.GetList();
var destination = await Node.GetNode(@"<ip>\dst", "<user>", "<password>");
foreach (var file in sourceFiles)
{
var stream = await file.Read();
await destination.Write(stream, file.Name);
await file.Delete();
}
await Task.Delay(5000);
}
Hi. First, thank you very much for this great library, it is very simple to use and it is a time saver.
Context
I'm trying to move files from UNC to UNC in a windows domain, running my application from a docker Linux container.
Testing environment
For testing this I have created the following file share on my local host
Then I Added 2 .txt files in \\localhost\src
Succeeded
My container was able to read the .txt files from the src folder with the following code
Failed
Although, when trying to use the
Move
method, I don't get any exceptions but the files are not moved as expectedAm I doing something wrong? should this code expect to move files from src to dst file share?