Kamran Shahid
Kamran Shahid

Reputation: 4124

Any method to check whether file is still in use on FTP location before downloading it locally

I am downloading files from FTP using WinSCP .NET library.

My code is

session.ExecutablePath = _appSettings["ApplicationFolderPath"] + "WinSCP.exe";
session.Open(sessionOptions);
var obj = session.ListDirectory(_appSettings["SFTP_IncomingFileFolder"]);

if (obj != null && obj.Files != null)
{
    foreach (RemoteFileInfo fileOrDo in obj.Files)
    {
        if (fileOrDo.Name == "." || fileOrDo.Name == ".." || fileOrDo.FileType == 'd' || fileOrDo.FileType == 'D')
        {
            continue;
        }

        // here I want's to check whether file is not in use  before calling  session.GetFiles(...,...).Check();
    }                    
 }

What I want's is to check file is not in use on FTP location before downloading it. Any idea what interface I should use.

Upvotes: 0

Views: 71

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202474

There's no way to test, if file is in use over FTP protocol.

Not only with WinSCP .NET assembly, but in general.


So all you can do is to try do download the file and gracefully handle any failure.

Upvotes: 1

Related Questions