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.
Imports WinSCP Try WriteInLogFile("Process Starts...") Dim sessionOptions As New SessionOptions With sessionOptions .Protocol = Protocol.Sftp .HostName = HostName .PortNumber = PortNumber .UserName = UserName .Password = Password .SshHostKey = SSHHostKey End With Using session As Session = New Session session.Open(sessionOptions) WriteInLogFile("Session starts...") Dim directory As RemoteDirectoryInfo = session.ListDirectory(SourcePath & FileType) ... WriteInLogFile("Process Ends...") End Using Catch e As Exception WriteInLogFile("Error : " & e.Message.ToString) End Try
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.