Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Commented Issue: Remote File exists not working [1574]

$
0
0
I've tried to use sftp.Exists(String) do not work for files. Already tested for file and for directory. Directory work well, but files are not recognized.
Comments: ** Comment from web user: mmoufakkir2 **

my changing the beloow method in sftpclient.cs from

public bool Exists(string path)
{
if (path.IsNullOrWhiteSpace())
throw new ArgumentException("path");

if (this._sftpSession == null)
throw new SshConnectionException("Client not connected.");

var fullPath = this._sftpSession.GetFullRemotePath(path);

if (this._sftpSession.RequestRealPath(fullPath, true) == null)
{
return false;
}
else
{
return true;
}
}


to

public bool Exists(string path)
{
if (path.IsNullOrWhiteSpace())
throw new ArgumentException("path");

if (this._sftpSession == null)
throw new SshConnectionException("Client not connected.");

var fullPath = this._sftpSession.GetCanonicalPath(path);

// Try to open as a file
var handle = this._sftpSession.RequestOpen(fullPath, Flags.Read, true);

if (handle == null)
{
handle = this._sftpSession.RequestOpenDir(fullPath, true);
}

if (handle == null)
{
return false;
}
else
{
this._sftpSession.RequestClose(handle);
return true;
}
}

the new code was taking form a old version of sshnet library.
good luck to all


Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>