This code will download the requested file, but then immediately throw the error "The file path does not exist or is invalid.". I do see a newly created file in the local folder.
using (var sftp = new SftpClient(FTPServer, 22, FTPUserID, FTPPwd))
{
sftp.Connect();
FileSourceName = FTPServer + FTPPath + @"/spot_performance.csv";
FileProcessName = FileProcessPath + @"\spot_performance.csv";
using (var fileStream = System.IO.File.OpenWrite(@"C:\Data\ETL\Innogames - SPOT Performance\spot_performance.csv"))
{
sftp.DownloadFile(FileSourceName, fileStream);
}
}
Okay, it was my fault. I assumed that "The file path does not exist or is invalid." was referring to the local path, not the remote path. Turns out I had an incorrect remote path. The download now completes.
My apologizes!