Question:
I am using FTP using TLS i.e., FTPS. I am trying to upload file from my local using FTPS. Getting Can't find file error though the file is present in physical location.
Code Snippet -
Chilkat.Ftp2 ftp = new Chilkat.Ftp2();
bool success;
// Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial");
if (success != true)
{
Console.WriteLine(ftp.LastErrorText);
return ftp.LastErrorText;
}
// If this example does not work, try using passive mode
// by setting this to true.
ftp.Passive = false;
ftp.Hostname = parameters.HostName;
ftp.Username = parameters.UserName;
ftp.Password = parameters.Password;
ftp.Port = 20017;
// We don't want AUTH SSL:
ftp.AuthTls = true;
// We want Implicit SSL:
ftp.Ssl = false;
// Connect and login to the FTP server.
success = ftp.Connect();
if (success != true)
{
Console.WriteLine(ftp.LastErrorText);
ftp.Disconnect();
return ftp.LastErrorText;
}
else
{
// LastErrorText contains information even when
// successful. This allows you to visually verify
// that the secure connection actually occurred.
Console.WriteLine(ftp.LastErrorText);
Console.WriteLine("FTPS Channel Established!");
success = ftp.ChangeRemoteDir("/");
if (success != true)
{
return ftp.LastErrorText;//Directory Change Error.
}
else
{
string localfilename = "c:/temp/test.txt";
string remotefilename = "test.txt";
success = ftp.PutFile(localfilename, remotefilename);
if (success != true)
{
//ftp.Disconnect();
return "---------Upload Error --------- " + ftp.LastErrorText + "---" ;//Upload Error.
}
else
{
ftp.Disconnect();
return "File Uploaded sucessfully.";
}
}
}
I am getting below error -
---------Upload Error --------- ChilkatLog: PutFile: DllDate: Aug 30 2017 ChilkatVersion: 9.5.0.69 UnlockPrefix: Anything for 30-day trial Architecture: Little Endian; 32-bit Language: .NET 4.5 VerboseLogging: 0 RemoteFilename: test.txt LocalFilename: c:/temp/test.txt ProgressMonitoring: enabled: yes heartbeatMs: 0 sendBufferSize: 65536 --ProgressMonitoring IdleTimeoutMs: 60000 ReceiveTimeoutMs: 60000 ConnectTimeoutSeconds: 30 soRcvBuf: 4194304 soSndBuf: 262144
Failed to open file (3)
utf8Filename: \\?\c:\temp\test.txt
osErrorInfo: The system cannot find the file specified.
localWindowsFilePath: c:\temp\test.txt
Failed to get local file size.
localFilePath: c:/temp/test.txt
Percent done event callbacks are disabled for this call.
uploadFromLocalFile:
Failed to open file (3)
utf8Filename: \\?\c:\temp\test.txt
osErrorInfo: The system cannot find the file specified.
localWindowsFilePath: c:\temp\test.txt
Failed to open file data source.
--uploadFromLocalFile
TotalTime: Elapsed time: 0 millisec
Failed.
--PutFile --ChilkatLog
Try in UNC format: "c:\temp\test.txt"
Added a image, because the forum don't show the UNC path when it's posted here.