When a path starts with "~", SftpSession.GetFullRemotePath does not handle it properly.
For instance,
```
SftpClient.Exists("~/somedir)
```
...does not do the check correctly.
I did a local fix by changing SftpSession.GetFullRemotePath to:
```
internal string GetFullRemotePath(string path)
{
var fullPath = path;
if (!string.IsNullOrEmpty(path) && path[0] == '~' && this.WorkingDirectory != null)
{
fullPath = path.Replace("~", this.WorkingDirectory);
}
else if (!string.IsNullOrEmpty(path) && path[0] != '/' && this.WorkingDirectory != null)
{
if (this.WorkingDirectory[this.WorkingDirectory.Length - 1] == '/')
{
fullPath = string.Format(CultureInfo.InvariantCulture, "{0}{1}", this.WorkingDirectory, path);
}
else
{
fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", this.WorkingDirectory, path);
}
}
return fullPath;
}
```
However I'm not 100% sure it is the correct fix, but it is a starting point to illustrate the issue.
For instance,
```
SftpClient.Exists("~/somedir)
```
...does not do the check correctly.
I did a local fix by changing SftpSession.GetFullRemotePath to:
```
internal string GetFullRemotePath(string path)
{
var fullPath = path;
if (!string.IsNullOrEmpty(path) && path[0] == '~' && this.WorkingDirectory != null)
{
fullPath = path.Replace("~", this.WorkingDirectory);
}
else if (!string.IsNullOrEmpty(path) && path[0] != '/' && this.WorkingDirectory != null)
{
if (this.WorkingDirectory[this.WorkingDirectory.Length - 1] == '/')
{
fullPath = string.Format(CultureInfo.InvariantCulture, "{0}{1}", this.WorkingDirectory, path);
}
else
{
fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", this.WorkingDirectory, path);
}
}
return fullPath;
}
```
However I'm not 100% sure it is the correct fix, but it is a starting point to illustrate the issue.