VB.NET: "The file exists." error while opening Session

Advertisement

Suresh
Joined:
Posts:
5
Location:
Malaysia

VB.NET: "The file exists." error while opening Session

Hi,

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.

Code Snippet

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

Error : The file exists.

The scheduler is running in local Adminstrator account.

Windows Server Details

Windows Server 2008 R2 Enterprise- 64 bit OS

WinSCP

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.

Thanks

Suresh

Reply with quote E-mail

Suresh
Joined:
Posts:
5
Location:
Malaysia

VB.NET: "The file exists." error while opening Session

Hi,

After I clear the temp folder, the scheduler is working fine.

Ref: https://winscp.net/forum/viewtopic.php?t=11184

But I wonder, why Winscp creates temp files in temp folder and why this problem is not occurred while executing the application manually.

Kindly let me know if anyone has information regarding this.

Thanks & Regards
Suresh

Reply with quote E-mail

martin
Site Admin
martin avatar
Joined:
Posts:
27,426
Location:
Prague, Czechia

Re: VB.NET: "The file exists." error while opening Session

Suresh wrote:

After I clear the temp folder, the scheduler is working fine.

Ref: https://winscp.net/forum/viewtopic.php?t=11184
This was know bug:
https://winscp.net/tracker/show_bug.cgi?id=849
You need to upgrade.

But I wonder, why Winscp creates temp files in temp folder
This is how it communicates with winscp.exe

and why this problem is not occurred while executing the application manually.
Possibly your interactive session uses a different temp folder than your schedulers session.

Reply with quote

Advertisement

You can post new topics in this forum