I developed an VB.NET application to monitor the files in SFTP folder periodically. The application uses Winscp.dll. I am using Windows Task scheduler and called the application.
I am getting following error while connecting WinScp using Session.Open method.
Dim sessionOptions As New SessionOptions
.Protocol = Protocol.Sftp
.HostName = HostName
.PortNumber = PortNumber
.UserName = UserName
.Password = Password
.SshHostKey = SSHHostKey
Using session As Session = New Session
Dim directory As RemoteDirectoryInfo = session.ListDirectory(SourcePath & FileType)
Catch e As Exception
WriteInLogFile("Error : " & e.Message.ToString)
Error : The file exists.
The scheduler is running in local Adminstrator account.
Windows Server Details
Windows Server 2008 R2 Enterprise- 64 bit OS
WinSCP 5.0.6 (Build 2074)
Kindly note that the Session opened properly when the same application executed manually by double clicking the exe.
Since the application is working fine when we execute manually and also the error message is not proper, we are unable to proceed our analysis.
Kindly suggest possible causes for this scenario and provide me a solution.