private string RemoteChangeDirectory(string path) { if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); } var dir = path.Substring(0, path.LastIndexOf('/') + 1); Telnet.ChangeFtpDirectory(dir); return(path.Replace(dir, string.Empty)); }