Hi,
I am currently developing a VB.NET application and I wanted to list out all txt file today’s file available in SFTP folder. The application uses Winscp.dll (version 5.0.6.0).
I am passing *.txt along with the sftp path to ListDirectory method
Example: /Test/*.txt
It downloads all files available in the /Test/ folder with .txt extension, then I am looping through each file and checking the file date time and filtering today’s file.
I found there is a Mask feature where we can specify the date time.
Ref:
https://winscp.net/eng/docs/file_mask
>yyyy-mm-dd[ hh:mm[:ss]]
Matches files modified the last time after the date or time (i.e. “newer than”).
>2012-01-01,>2012-02-29 08:47
But when I pass the File Mask to List Directory method, it is not supported.
I believe I am missing some points here, please help.
Code Snippet
Imports WinSCP
Try
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)
Dim directory As RemoteDirectoryInfo = session.ListDirectory("/Test/*.txt>2014-02-21")
...
End Using
Catch e As Exception
WriteInLogFile("Error : " & e.Message.ToString)
End Try
WinSCP
WinSCP 5.0.6 (Build 2074)
Kindly note that I don’t want to download the file.
Thanks
Suresh