Im trying to move a file from one location to another.
private void SendFileToDestination()
{
string file = "HATKANOT_BETIHOT_231230.txt";
string sourceFilePath = Path.Combine(@"FTPUSERS\hoz_tbr\from\", file);
string destinationFilePath = Path.Combine(@"C:\ARCHIVE\dgamim\CompanyC\", file);
File.Copy(sourceFilePath, destinationFilePath);
}
Ive hardcoded the paths since I was trying to overcome the issue Im going to detail below, but, the issue kept occuring.
So, the issue is that I get this error:
System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'E:\GalWorkspace\workspace\SlikaNetCore\Dgamim\bin\Debug\net8.0\FTPUSERS\hoz_tbr\from\HATKANOT_BETIHOT_231230.txt'.'
Im not sure why its looking under the entire E:\GalWorkspace\workspace\SlikaNetCore\Dgamim\bin\Debug\net8.0
as I never mentioned it in my code.
What am I missing?
I was obviously expecting it to be transfered from one hardcoded location to another.
FTPUSERS\hoz_tbr\from\file, this will be relative to something, which, depending on how you start the process, can be the folder where the executable is located. If you are talking about a specific folder named FTPUSERS, you should use an absolute path to it, such asE:\FTPUSERS\...or similar.